Good little programmers define variables before
using them, or at least before evaluating them.
print $undefined; // E_NOTICE error
The most common use of this is:
if ($submit) {
To check if a form submit button named submit
has been submitted. If not, this does indeed
evaluate to false BUT also an error of level E_NOTICE
is created. So, one might do the following,
which will never give E_NOTICE:
if (isset($submit)) {
At any rate, the reason is your error levels
are different. Look up the error_reporting
directive:
http://www.php.net/manual/en/configuration.php#ini.error-reporting
A function also controls this behavior within scripts,
it's appropriatly named error_reporting()
http://www.php.net/error_reporting
So, start programming your code with error_reporting(E_ALL)
and have fun!
Regards,
Philip Olson
p.s. Although it's fairly common to create E_NOTICE all over
the place, it's not a good idea. More and more people are
learning to not do that.
On Tue, 2 Apr 2002, kip wrote:
> Hi,
>
> As i know we don't need to define a variable before in PHP. But i have a
> very strange case. In my server, i hosted a PHP website. When i update the
> server from PHP3 to PHP4, problems came out. Most of the php pages didn't
> work and display many warnings like that :
> "Warning: Undefined variable: variable_name". In fact, nobody has changed
> the code and all of the pages are working property in PHP3 server. So, does
> anyone know what happen? I also contact the hosting company, but they said
> that everything is working fine and they don't know what problem is it.
> Thats why i have no idea how to correct it.
>
> Thanks.
> Kenny
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php