Bug #13724 Updated: assert does not work as documented
| From: | yasuo_ohgaki at yahoo dot com | Date: | Thu, 18 Oct 2001 04:05:55 +0000 |
| Subject: | Bug #13724 Updated: assert does not work as documented | ||
| References: | 1 | Groups: | php.dev php.doc |
| Request: | Send a blank email to php-dev+get-68187@lists.php.net to get a copy of this message | ||
ID: 13724
User updated by: yasuo_ohgaki@yahoo.com
Reported By: yasuo_ohgaki@yahoo.com
Status: Open
Old Bug Type: Scripting Engine problem
Bug Type: Documentation problem
Operating System: Linux 2.4.4/glibc 2.2.2
PHP Version: 4.0CVS-2001-10-17
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2001-10-17 23:46:37] yasuo_ohgaki@yahoo.com
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