#48937 [Opn]: Strict standards: Only variables should be passed by reference

From: Date: Thu, 16 Jul 2009 13:42:33 +0000
Subject: #48937 [Opn]: Strict standards: Only variables should be passed by reference
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2497@lists.php.net to get a copy of this message
ID: 48937 Updated by: rasmus@php.net Reported By: software at whatsonyourbrain dot com Status: Open Bug Type: Documentation problem Operating System: Win XP SP3 PHP Version: 5.3.0 New Comment: Not at all, simply do: $parts = explode('/',$item); $itemsArray[]= end($parts); If you want to use end() in this case. Previous Comments: ------------------------------------------------------------------------ [2009-07-16 13:36:50] software at whatsonyourbrain dot com What is the proper way of coding with end(), for strict standards-- so that its use is not erroneous? It would seem the instructions provided [@16 Jul 2:56am UTC] are directing the user to avoid use of "end()". Should I assume that "end()" itself will be deprecated? ------------------------------------------------------------------------ [2009-07-16 02:56:22] rasmus@php.net Converting to an array doesn't make much sense here. You are just doing simple string stuff. I would change it to: $itemsArray[]= substr(strrchr($item,'/'),1); ------------------------------------------------------------------------ [2009-07-16 01:59:05] software at whatsonyourbrain dot com please advise [@16 Jul 12:56am]. (i.e. what is the proper way of coding this procedure, or-- what is the proper way of coding this procedure to avoid error?) ------------------------------------------------------------------------ [2009-07-16 00:58:09] rasmus@php.net I guess we can leave it open as a documentation problem instead. ------------------------------------------------------------------------ [2009-07-16 00:56:45] rasmus@php.net end() takes the array by reference since it tries to modify the array (by changing the array pointer) and because there is nowhere to store that change you end up with that error. If it only returned the last element, you wouldn't see this warning because it wouldn't need to be passed by reference. ------------------------------------------------------------------------ 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/48937 -- Edit this bug report at http://bugs.php.net/?id=48937&edit=1

« previous php.doc.bugs (#2497) next »