#14285 [Com]: Forcing variable declaration

From: Date: Thu, 22 Jul 2004 07:49:26 +0000
Subject: #14285 [Com]: Forcing variable declaration
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-63318@lists.php.net to get a copy of this message
ID: 14285 Comment by: jeffrparsons at optushome dot com dot au Reported By: pnh102 at psu dot edu Status: Open Bug Type: Feature/Change Request Operating System: Redhat Linux 7.2 PHP Version: 4.0.6 New Comment: I agree this is a very major issue, and it scares people I know away from using PHP. It would be extremely convenient to have warnings on assignment as well - instead of just upon reading a non-existent variable - and instead of creating a variable when a value is first assigned to it, require a separate declaration using a "var" keyword or such. Obviously not as standard, but as an option... Previous Comments: ------------------------------------------------------------------------ [2003-08-13 14:35:52] lsemel at yahoo dot com This is an important issue. E_ALL doesn't catch everything. It makes PHP harder to program compared to other languages where you can declare variables (Perl, Java, etc.) ------------------------------------------------------------------------ [2003-07-16 15:36:44] andrew_nefsky at hotmail dot com This is definitely an important issue. Not being able to declare variables creates a debugging nightmare! ------------------------------------------------------------------------ [2002-11-19 08:06:07] z95kahe at mtek dot chalmers dot se I realy think this is good idea. I've been looking for some tool to do this kind of checks and found none. For small scripts there is no need to have variable declaring but there are for longer multi file, multi developer projects. By making the checks an option we can have both modes available. ------------------------------------------------------------------------ [2001-11-29 11:39:07] hholzgra@php.net this would only catch read usage of undefined variables, but not assigning values to them see: <?php $typofree = "hallo"; ... $xtypofree = "ooops"; ?> nothing in PHP will warn you that you have a typo in the second assignment, so creating a new variable unintended ... moved to feature requests ... ------------------------------------------------------------------------ [2001-11-29 11:20:18] derick@php.net set error_reporting to E_ALL, and you'll see all undefined vars. However, it doesn't force the use of it. Derick ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/14285 -- Edit this bug report at http://bugs.php.net/?id=14285&edit=1

« previous php.bugs (#63318) next »