Database Reference
In-Depth Information
function strip_slash_helper ( $val )
{
if ( ! is_array ( $val ))
$val = stripslashes ( $val );
else
{
foreach ( $val as $k => $v )
$val [ $k ] = strip_slash_helper ( $v );
}
return ( $val );
}
strip_slash_helper() checks whether a value is a scalar or an array and processes it
accordingly. It uses a recursive algorithm for array values because in PHP it's possible
to create nested arrays from input parameters.
To make it easy to obtain a list of all parameter names, use another utility function:
function get_param_names ()
{
# construct an array in which each element has a parameter name as
# both key and value. (Using names as keys eliminates duplicates.)
$names = array ();
foreach ( array_keys ( $_GET ) as $name )
$names [ $name ] = $name ;
foreach ( array_keys ( $_POST ) as $name )
$names [ $name ] = $name ;
return ( $names );
}
get_param_names() returns a list of parameter names present in the HTTP variable
arrays, with duplicate names removed if there is overlap between the arrays. The return
value is an array with its keys and values both set to the parameter names. This way you
can use either the keys or the values as the list of names. The following example prints
the names, using the values:
$param_names = get_param_names ();
foreach ( $param_names as $name )
print ( htmlspecialchars ( $name ) . "<br />" );
To construct URLs that point to PHP scripts and that have parameters at the end, sep‐
arate the parameters by & characters. To use a different character (such as ; ), change the
separator by setting the arg_separator configuration variable in the PHP initialization
file.
Python. The Python cgi module provides access to input parameters that are present
in the script environment. Import that module, then create a FieldStorage object:
import cgi
params = cgi . FieldStorage ()
Search WWH ::




Custom Search