...

View Full Version : Variable Declaration



eeijlar
08-05-2008, 02:28 PM
Hi,

I have just started using PHP and I am wondering if there is a PHP equivalent of Perl's


use strict;

or


my $var;

It seems to me that variables are used without declaration or initialisation...

/jlar

malfist
08-05-2008, 02:30 PM
That is correct, PHP is a weakly typed language. Which means you don't have to predeclare a variable, and variables do not have assigned types and can change at any time.

edit: Personally, I don't like it, but that's how it is.

chaosprime
08-05-2008, 04:38 PM
The best PHP can do toward acting like 'use strict' is error_reporting(E_ALL). This gets you many warnings related to variable definition and can occasionally help you catch things. It's still not nearly as good as 'use strict'.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum