By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,963 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,963 IT Pros & Developers. It's quick & easy.

Is there a setting to allow $var = "" when POST and GET vars are strict?

P: n/a
I have the following problem: $_POST["val"] and $_GET["val"] variables can
only be used when in the correct format (not $val), but when I define a
variable within my PHP page (eg $internal_var = "value" ) it doesn't work
and is not found. Why is this?

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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
sam
"Keiron Waites" <webmaster@-NOSPAM-sharemonkey.com> wrote in message
news:bl**********@hercules.btinternet.com...
I have the following problem: $_POST["val"] and $_GET["val"] variables can
only be used when in the correct format (not $val), but

You have in your php.ini file register_globals = off
That's why you can use $_GET['val'] , $_POST['val'] but not $val
when I define a variable within my PHP page (eg $internal_var = "value" )
it doesn't work and is not found. Why is this?
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.
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

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.