Skip to the content
Documentation

ezhttp

No ratings yet

Summary

Returns GET, POST and session variables.

Usage

ezhttp( name [, type ] )

Parameters

Name Type Description Required
name string The HTTP variable that should be fetched. Yes.
type string Source of variable. Default is is HTTP POST. No.

Returns

Variable value

Description

This operator makes it possible to inspect the contents of HTTP variables (POST, GET or session variables). The "type" parameter can be used to specify which type of variable that should be extracted. The following options are available:

  • post (POST variable)
  • get (GET variable)
  • session (session variable)

Examples

Example 1
{ezhttp( 'search' )}

Returns the "search" POST variable.

Example 2
{ezhttp( 'image', 'get' )}

Returns the "image" GET variable.

Example 3
{ezhttp( 'user_id', 'session' )}

Returns the "user_id" session variable.

Contributors

Comments (8 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. Warnings

    Bertrand Dunogier ·

    It's a little too bad there's no way to avoid a warning when the variable we're fetching is not set ...

    1. Re: Warnings

      James Robertson ·

      You only recieve a warning? I get see an error. Most annoying!

      1. Re: Re: Warnings

        Patrick Kaiser ·

        using 3.7.4 and getting an error as well. even testing for the existence fo a get/post var throws an error:
        {if ezhttp( 'myvar', 'get' ) } => returns false, but throws error
        the same with {if is_set( ezhttp( 'myvar', 'get' ) )}
        its a bug in my opinion..

    2. Re: Warnings

      VaL ·

      you can use in 3.9 (trunk) like:
      ezhttp_hasvariable( 'getVar','get' )
      or
      ezhttp( 'getVar','get','hasVariable' )

  2. Why not ?

    Alimi Nabil ·

    It would be nice if the ezhttp operator could return all vars in the array specified. ezhttp(GET) would return all $_GET vars for example.

    1. Re: Why not ?

      Esteban Rodriguez ·

      You actually can get all the $_GET variables, or $_POST.
      {def $foobar=ezhttp()}
      This brings you all the http variables, be them get, post or session, in an array. You can check them out doing:
      {$foobar|attribute(show)}

  3. ezhttp is not working if caching is turned on.

    vytis ·

    i put
    {set-block scope=root variable=cache_ttl}0{/set-block}
    to all templates, because in other way ezhttp will return the same value...

  4. or null

    Pike ·

    Returns:
    Variable value or null
    test for non-existence using
    {if not(ezhttp('test'))}
    or
    {if ezhttp('test')|null()}

Comments

Add a comment

Comments are read by a moderator before they appear.