|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-10-18 00:05 UTC] yasuo_ohgaki at yahoo dot com
[2001-11-24 16:09 UTC] georg@php.net
[2001-11-24 21:35 UTC] yasuo_ohgaki at yahoo dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 14:00:01 2025 UTC |
According to the manual, assert() accepts string or boolean. However, it seems assert() does handle string type well, especially if it's a class property. (Parse error) Either PHP or the manual page is wrong. Following code does not work well. == code #1 == <?php class A { var $name = 'class A'; function print_name() { assert($this->name); print $this->name; } } $obj1 = new A; $obj1->print_name(); ?>== result #1 == Parse error: parse error in /home/yohgaki/public_html/test/bug/obj_property/test.php(7) : assert code on line 1 Fatal error: Failure evaluating code: class A in /home/yohgaki/public_html/test/bug/obj_property/test.php on line 7 == code #2 == <?php $str1 = ''; $str2 = 'abc'; assert($str1); assert($str2); ?> == result #2 ==Warning: Assertion "" failed in /home/yohgaki/public_html/test/bug/obj_property/test2.php on line 5 Warning: Use of undefined constant abc - assumed 'abc' in /home/yohgaki/public_html/test/bug/obj_property/test2.php(6) : assert code on line 1 == code #3 == <?php $arr = array('abc'); assert($arr['abc']); ?> == result #3 == Warning: Undefined index: abc in /home/yohgaki/public_html/test/bug/obj_property/test3.php on line 4 Warning: Assertion failed in /home/yohgaki/public_html/test/bug/obj_property/test3.php on line 4