#38824 [Opn->WFx]: settype() should throw a Notice on uninitialized variables

From: Date: Thu, 14 Sep 2006 11:16:55 +0000
Subject: #38824 [Opn->WFx]: settype() should throw a Notice on uninitialized variables
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-102163@lists.php.net to get a copy of this message
ID: 38824 Updated by: tony2001@php.net Reported By: tklingenberg at lastflood dot com -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: win32 PHP Version: 5.1.6 New Comment: It's just impossible. settype() function accepts the first parameter by reference. See fo example: <?php function create_a_var(&$var) { $var = 'created'; } create_a_var($doesnt_exist); // you would not expect a NOTICE here, right? ?> settype() does the same. Previous Comments: ------------------------------------------------------------------------ [2006-09-14 11:07:13] tklingenberg at lastflood dot com Description: ------------ In case a program uses an uninitialized variable passed to settype(), it should throw a Notice, compareable to echo; intval() and other variable related functions. Even if PHP does everything right ($var is a variable you can change the type of), for the PHP User, it's highly possible she/he made an error and typed in the wrong variable name. Afterwards the type of the variable is unchecked, which can lead to even more critical errors. All this is unnoticed because PHP does not throw a NOTICE. Reproduce code: --------------- <?php $r = settype($var, "float"); ?> Expected result: ---------------- It should throw a Notice Actual result: -------------- No Notice is giving that $var is not initialized. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38824&edit=1

« previous php.bugs (#102163) next »