#38821 [NEW]: settype() creates variable "by reference"
| From: | tklingenberg at lastflood dot com | Date: | Thu, 14 Sep 2006 09:51:05 +0000 |
| Subject: | #38821 [NEW]: settype() creates variable "by reference" | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-102152@lists.php.net to get a copy of this message | ||
From: tklingenberg at lastflood dot com
Operating system: win32
PHP version: 5.1.6
PHP Bug Type: Variables related
Bug description: settype() creates variable "by reference"
Description:
------------
settype() needs a variable passed by reference.
if this variable is not defined/set, it does not throw an error. instead,
and that is the bug per se, settype creates the variable passed "by
reference".
Reproduce code:
---------------
<?
/* $var does not exsits, this throws an error */
var_dump($var);
/* settype should work on existing vars only (by &reference) */
$r = settype($var, "string");
/* $var does exist now */
var_dump($var);
?>
Expected result:
----------------
<br />
<b>Notice</b>: Undefined variable: var in <b>test.php</b> on line
<b>3</b><br />
NULL
<br />
<b>Notice</b>: Undefined variable: var in <b>test.php</b> on line
<b>6</b><br />
NULL
Actual result:
--------------
<br />
<b>Notice</b>: Undefined variable: var in <b>test.php</b> on line
<b>3</b><br />
NULL
string(0) ""
--
Edit bug report at http://bugs.php.net/?id=38821&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38821&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38821&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38821&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=38821&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=38821&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=38821&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=38821&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=38821&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=38821&r=support
Expected behavior: http://bugs.php.net/fix.php?id=38821&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=38821&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=38821&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=38821&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38821&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=38821&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=38821&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=38821&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=38821&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=38821&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=38821&r=mysqlcfg