Date: 11/26/02
- Next message: bsdpunk <email protected>: "[PHP-DOC] #19640 [Com]: Too many docs mirrors - Yes, I think it's a bug."
- Previous message: swbrown <email protected>: "[PHP-DOC] #20663 [NEW]: trigger_error silently truncates the error to 1024 chars."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 19699
Comment by: tater <email protected>
Reported By: fvu <email protected>
Status: Open
Bug Type: Documentation problem
Operating System: Windows
PHP Version: 4.2.3,4.3.0-dev
New Comment:
Why not just add a flag parameter to array_walk() saying that the
userdata param should be a reference?
If "future versions may not support this any longer", there will be no
way for array_walk to modify external variables, and that's a serious
BC problem.
Previous Comments:
------------------------------------------------------------------------
[2002-10-04 03:04:31] fvu <email protected>
James,
indeed your example would break existing code if '$userdata' would
*always* be passed by reference.
I think the solution would be to let array_walk pass '$userdata' by
reference only if specified so in 'my_function' (just the same as the
first parameter behaves).
Your example would still work then since '$userdata' in my_function()
is specified without an ampersand, so it should be passed by value.
------------------------------------------------------------------------
[2002-10-03 19:38:55] sniper <email protected>
updated version information.
------------------------------------------------------------------------
[2002-10-03 16:27:08] jmoore <email protected>
OK.
Manual is incorrect here, in PHP4 functions either specify if an arg is
passed by ref or by value. In array_walk only the first argument is
ever passed by reference. I can see that passing userdata by reference
would be nice but unfortuantly it is too much of a big change that
could break too many scripts to make as this point as people may be
relying on the fact it is passed by reference.
For example
function my_function($value, $key, $userdata)
{
$userdata = strrev($userdata.$key.$value);
}
$array1 = array("one", "two", "three")l
$mydata = "array1";
array_walk($array1, 'my_function', $mydata);
This POOR example would not work with thrid parameter passed by ref so
for now am changing this to a documentation problem as the
documentation is currently slightly misleading in it advocates using
calltime pass by reference when infact the first param only is ever
passed by reference.
- James
------------------------------------------------------------------------
[2002-10-03 15:50:01] fvu <email protected>
I tried using the latest snapshot for Windows:
System Windows 9x localhost 4.10
Build Date Oct 3 2002 20:15:03
but I still encounter the same problems.
------------------------------------------------------------------------
[2002-10-01 18:51:35] sniper <email protected>
Please try using this CVS snapshot:
http://snaps.php.net/php4-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-latest.zip
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/19699
-- Edit this bug report at http://bugs.php.net/?id=19699&edit=1-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: bsdpunk <email protected>: "[PHP-DOC] #19640 [Com]: Too many docs mirrors - Yes, I think it's a bug."
- Previous message: swbrown <email protected>: "[PHP-DOC] #20663 [NEW]: trigger_error silently truncates the error to 1024 chars."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

