| re: Is there a setting to allow $var = "" when POST and GET vars are strict?
"Keiron Waites" <webmaster@-NOSPAM-sharemonkey.com> wrote in message
news:bleeki$bna$1@hercules.btinternet.com...[color=blue]
> I have the following problem: $_POST["val"] and $_GET["val"] variables can
> only be used when in the correct format (not $val), but[/color]
You have in your php.ini file register_globals = off
That's why you can use $_GET['val'] , $_POST['val'] but not $val
[color=blue]
> when I define a variable within my PHP page (eg $internal_var = "value" )
> it doesn't work and is not found. Why is this?[/color]
All user_defined variables are visible only within the scope
they are defined in.
To use them within another scope use the 'global' directive:
Ex:
$my_var = "blabala";
function getIt()
{
echo $my_var; // this will print nothing
// because $my_var is invisible
// here
}
To make the function works:
function getIt()
{
global $my_var; // import $my_var in this scope
echo $my_var; // this will print 'blabala'
}
HTH.
[color=blue]
> I have this code in an Apache .htaccess file:
>
> <IfModule mod_rewrite.c>
> RewriteEngine On
> RewriteBase /
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule (.*) /ShareMonkey.net/Web/index.php
> </IfModule>
>
> Do I need to add some extra code to allow for internal variables?
>
> TIA
>
>[/color] |