Re: Simple Unidentified Variable
| From: | Philip Olson | Date: | Wed, 08 May 2002 17:38:04 +0000 |
| Subject: | Re: Simple Unidentified Variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-96611@lists.php.net to get a copy of this message | ||
Hi,
Everyone makes it sounds that since 4.2.0 it's
impossible to do:
http://www.example.com/foo.php?a=apple
print $a; // apple
It is still very possible. The main way to make
this possible is via the register_globals directive,
a PHP setting that can be changed in PHP's
configuation file, php.ini The default of this
directive changed from on to off as of 4.2.0,
this is just the default. Everyone should read
php.ini as it contains information about many
directives that affect our scripts. Please do
not hesitate to ponder over php.ini:
http://cvs.php.net/co.php/php4/php.ini-dist
There are several ways to "reflect" the behavior
of register_globals, methods include:
0) turning it on in php.ini (sysadmin)
a) .htaccess : if the sysadmin allows use of
.htaccess, then the following will work in
it:
php_flag register_globals on
b) use extract() or import_request_variables()
c) don't code with this behavior
Check the archives for more tips, I've ranted
a few times in the recent past :) Such as:
http://marc.theaimsgroup.com/?l=php-general&m=102036870428992
And btw, undefined variable errors are of level
E_NOTICE and configured via either the
error_reporting directive in php.ini or at
runtime via the error_reporting() function.
Regards,
Philip Olson
On Wed, 8 May 2002, Analysis & Solutions wrote:
> Hi Jeremy:
>
> On Wed, May 08, 2002 at 01:06:16PM +0800, Jeremy wrote:
> >
> > I am very new to PHP and when doing the tutorial on the mysql site, ...
> >
> > Notice: Undefined variable: "value" in .....\welcome.php on line 2
> >
> > even though they have been entered in the html form and they are in
> > $HTTP_POST_VARS.
>
> Things have changed in PHP. GET and POST variables are no longer
> automatically globalized. Use "$_POST['value']" rather than
> "$value."