[PHP] Variables not initialized. Is it possible to...
Is it possible to set a parameter in PHP 5 to ask the interpreter to raise an error every time I try to use a variable that wasn't initialized before ? For example, I've write this piece of code in Python: print(DonaldDuck) I get this error: Traceback (most recent call last): File /Users/Cesco/Desktop/prova.py, line 3, in module print(DonaldDuck); NameError: name 'DonaldDuck' is not defined Until now I've seen that when I write this PHP equivalent: echo($DonaldDuck); When I try to run it, the PHP writes a blank string, because the variable is not yet initialized and PHP assumes that its value is an empty string (I guess) I'd like to have the same behaviour of Python in PHP, do you think that it is possible? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not initialized. Is it possible to...
On Mon, May 18, 2009 at 05:38:37PM +0200, Cesco wrote: Is it possible to set a parameter in PHP 5 to ask the interpreter to raise an error every time I try to use a variable that wasn't initialized before ? For example, I've write this piece of code in Python: print(DonaldDuck) I get this error: Traceback (most recent call last): File /Users/Cesco/Desktop/prova.py, line 3, in module print(DonaldDuck); NameError: name 'DonaldDuck' is not defined Until now I've seen that when I write this PHP equivalent: echo($DonaldDuck); When I try to run it, the PHP writes a blank string, because the variable is not yet initialized and PHP assumes that its value is an empty string (I guess) I'd like to have the same behaviour of Python in PHP, do you think that it is possible? Set your error reporting higher: error_reporting(E_ALL); at the top of your script. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not initialized. Is it possible to...
This kind of tip is raised in form of notices. So, to enable that, use the following function on top of your scripts: error_reporting(E_ALL | E_NOTICE); Best regards, Bruno. 2009/5/18 Paul M Foster pa...@quillandmouse.com On Mon, May 18, 2009 at 05:38:37PM +0200, Cesco wrote: Is it possible to set a parameter in PHP 5 to ask the interpreter to raise an error every time I try to use a variable that wasn't initialized before ? For example, I've write this piece of code in Python: print(DonaldDuck) I get this error: Traceback (most recent call last): File /Users/Cesco/Desktop/prova.py, line 3, in module print(DonaldDuck); NameError: name 'DonaldDuck' is not defined Until now I've seen that when I write this PHP equivalent: echo($DonaldDuck); When I try to run it, the PHP writes a blank string, because the variable is not yet initialized and PHP assumes that its value is an empty string (I guess) I'd like to have the same behaviour of Python in PHP, do you think that it is possible? Set your error reporting higher: error_reporting(E_ALL); at the top of your script. Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Variables not initialized. Is it possible to...
Thank you Il giorno 18/mag/09, alle ore 18:15, Bruno Fajardo ha scritto: This kind of tip is raised in form of notices. So, to enable that, use the following function on top of your scripts: error_reporting(E_ALL | E_NOTICE); Best regards, Bruno. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php