ID: 41205 Comment by: judas dot iscariote at gmail dot com Reported By: paul at santasoft dot com Status: Open Bug Type: Documentation problem Operating System: centos (linux) PHP Version: Irrelevant New Comment:
<?php list($bobdole) = 'Bob Dole Smells Like Old Socks!'; echo($bobdole); ?> atal error: Invalid opcode 98/1/1.was a bug already fixed in CVS. however there $bobdole should be set to NULL and not to "B" as you expect ( or at least that is the bahviuor it has in CVS) IMHO it should trow a fatal error: "cannot use string as an array" Previous Comments: ------------------------------------------------------------------------ [2007-04-26 16:45:49] paul at santasoft dot com Description: ------------ clarification is needed in the documentation in the case of a one-to-one assignment using list() and a string. see reproduction code example 1. i understand that in this case, the string is being treated as an array of characters. But this was not as expected initially. Plus, a fatal error is generated if the string is directly provided instead of returning from a function. Inconsistent and confusing. Reproduce code: --------------- Example 1: <?php function bob_dole_is_a_dork() { return 'Bob Dole Smells Like Old Socks!'; } list($bobdole) = bob_dole_is_a_dork(); echo($bobdole); ?> Example 2: <?php list($bobdole) = 'Bob Dole Smells Like Old Socks!'; echo($bobdole); ?> Expected result: ---------------- Example 1: Bob Dole Smells Like Old Socks! Example 2: Bob Dole Smells Like Old Socks! Actual result: -------------- Example 1 gives: B Example 2 gives: Fatal error: Invalid opcode 98/1/1. in /the/path/doesnt/matter/pp.php on line 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41205&edit=1