variable declaration

php.internals

Alain Williams

19 years ago
Hi, just trying to canvass support for the ability to enforce declaration of variables as with perl's use strict: http://bugs.php.net/bug.php?id=39091
-- Alain Williams Parliament Hill Computers Ltd. Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ #include <std_disclaimer.h>

Ilia A.

19 years ago
If you want to emulate perl's "strict" mode just add an error_handler () that will catch E_NOTICE relating to undefined variable, constant, array key usage and convert them to fatal errors. On 10-Oct-06, at 2:52 PM, Alain Williams wrote:
> Hi, > > just trying to canvass support for the ability to enforce > declaration of variables as with perl's use strict: > > http://bugs.php.net/bug.php?id=39091
Ilia Alshanetsky

Alain Williams

19 years ago
On Tue, Oct 10, 2006 at 02:59:45PM -0400, Ilia Alshanetsky wrote:
> If you want to emulate perl's "strict" mode just add an error_handler > () that will catch E_NOTICE relating to undefined variable, constant, > array key usage and convert them to fatal errors.
No, it doesn't do the same thing, it won't pick up the following: $fo0 = 'bill'; ... $foo = 'ben'; One is a typeo.
> On 10-Oct-06, at 2:52 PM, Alain Williams wrote: > > http://bugs.php.net/bug.php?id=39091
-- Alain Williams Parliament Hill Computers Ltd. Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ #include <std_disclaimer.h>

Etienne Kneuss

19 years ago
Hi Variables' names are case-sensitive in PHP, $a = $A are two separate variables. How would you want to guess which one is right? -E Alain Williams a écrit :
> On Tue, Oct 10, 2006 at 02:59:45PM -0400, Ilia Alshanetsky wrote: > >> If you want to emulate perl's "strict" mode just add an error_handler >> () that will catch E_NOTICE relating to undefined variable, constant, >> array key usage and convert them to fatal errors. >> > > No, it doesn't do the same thing, it won't pick up the following: > > $fo0 = 'bill'; > ... > $foo = 'ben'; > > One is a typeo. > > >> On 10-Oct-06, at 2:52 PM, Alain Williams wrote: >> >>> http://bugs.php.net/bug.php?id=39091 >>> > >
-- Etienne Kneuss http://www.colder.ch/ colder@php.net

Ilia A.

19 years ago
On 10-Oct-06, at 3:51 PM, Alain Williams wrote:
> On Tue, Oct 10, 2006 at 02:59:45PM -0400, Ilia Alshanetsky wrote: >> If you want to emulate perl's "strict" mode just add an error_handler >> () that will catch E_NOTICE relating to undefined variable, constant, >> array key usage and convert them to fatal errors. > > No, it doesn't do the same thing, it won't pick up the following: > > $fo0 = 'bill'; > ... > $foo = 'ben';
Both of these represent valid syntax as far as I am concerned and should not generate errors. Ilia Alshanetsky