ID: 13724 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Old Summary: assert does not work as documented Old Status: Analyzed Status: Closed Bug Type: Documentation problem Old Operating System: Linux 2.4.4/glibc 2.2.2 Operating System: linux 2.4.4/glibc 2.2.2 Old PHP Version: 4.0CVS-2001-10-17 PHP Version: 4.1.0RC1 New Comment:
It looks document is updated. Closed. Previous Comments: ------------------------------------------------------------------------ [2001-11-24 16:09:22] [EMAIL PROTECTED] assert needs a parameter, which will be evaluated as PHP code, as described in the manual: "assert() will check the given assertion and take appropriate action if its result is FALSE. If the assertion is given as a string it will be evaluated as PHP code by assert(). " I don't know what should be wrong in the documentation. Georg ------------------------------------------------------------------------ [2001-10-18 00:05:55] [EMAIL PROTECTED] I've take a look at assert.c. assert() expects string to eval. So I guess if it doesn't work with object property, it would be okay. Document does not explain string must be a valid PHP code, so I changed this report to documentation problem. ------------------------------------------------------------------------ [2001-10-17 23:46:37] [EMAIL PROTECTED] 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 ------------------------------------------------------------------------ Edit this bug report at http://bugs.php.net/?id=13724&edit=1