#47369 [NEW]: use of {self::$} in a string always triggers Notice: Undefined variable:
| From: | d4n at digitalanalogue dot org | Date: | Thu, 12 Feb 2009 13:26:42 +0000 |
| Subject: | #47369 [NEW]: use of {self::$} in a string always triggers Notice: Undefined variable: | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-1843@lists.php.net to get a copy of this message | ||
From: d4n at digitalanalogue dot org
Operating system: CentOS 5
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: use of {self::$} in a string always triggers Notice: Undefined variable:
Description:
------------
Can you update the strings document to explain why you cannot use
self::$var in any string, or if you can what php version it works in.
I do not know if this is a bug, or if it is my php version, but I can't
understand why I can access the var and echo it out yet when I put it in a
string using escaped methods it is ignored and throws a notice saying
undefined when it clearly is!
Thanks
Dan
Reproduce code:
---------------
class user {
private static $table = "foo";
public function user() {
//blah...
}
public static function test() {
$str = "table = ". self::$table . "<br/>";
echo $str;
// Outputs: table = foo
$str = "table = {self::$table} <br/>";
echo $str;
// Outputs:
// Notice: Undefined variable: table in /*** on line ***
$str = '{self::$table}' . "<br/>";
echo $str;
// Outputs: table = {self::}
$str = <<<EOD
table = self::$table
EOD;
/*
Outputs:
Notice: Undefined variable: table in /*** on line ***
table = self::
*/
echo $str;
}
}
Expected result:
----------------
table = foo
table = foo
table = {self::$table}
table = foo
Actual result:
--------------
table = foo
Notice: Undefined variable: table in /*** on line ***
table = {self::}
table = {self::$table} // correct!
Notice: Undefined variable: table in /*** on line ***
table = self::
--
Edit bug report at http://bugs.php.net/?id=47369&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47369&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47369&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47369&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=47369&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47369&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=47369&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=47369&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=47369&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=47369&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=47369&r=support
Expected behavior: http://bugs.php.net/fix.php?id=47369&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=47369&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=47369&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=47369&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47369&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47369&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=47369&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=47369&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=47369&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=47369&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=47369&r=mysqlcfg