I made this change back in December.
I guess I could revert back but I think it makes sense to be strict here.
What does the rest think?

Andi

At 03:49 AM 4/27/2004 +0000, Curt Zirzow wrote:

I can't seem to find any discussion on this BC issue, so forgive me if
this has already been discussed.

Given the following;

$a = 'a string';

/* E_ERROR Cannot use string offset as an array */
echo is_array($a['bar']['baz']);

/* non error resolution */
echo isset($a['bar']['baz']) && is_array($a['bar']['baz']);


I'm not sure, but the patch below does seem to make the E_ERROR get demoted to a E_WARNING, thus fixing it so execution simply doesn't stop when a string is referenced improperly. Or is it a *must* that php needs to stop in this case?


Index: zend_execute.c =================================================================== RCS file: /repository/ZendEngine2/zend_execute.c,v retrieving revision 1.643 diff -u -r1.643 zend_execute.c --- zend_execute.c 15 Apr 2004 21:32:34 -0000 1.643 +++ zend_execute.c 27 Apr 2004 02:39:52 -0000 @@ -898,7 +898,9 @@ zval ***retval = &T(result->u.var).var.ptr_ptr;

        if (!container_ptr) {
-               zend_error(E_ERROR, "Cannot use string offset as an array");
+               *retval = &EG(uninitialized_zval_ptr);
+               zend_error(E_WARNING, "Cannot use string offset as an array");
+               return;
        }

container = *container_ptr;



Curt
--
"I used to think I was indecisive, but now I'm not so sure."

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to