ID: 24687 Comment by: kain at kuht dot it Reported By: nologic at pchome dot com dot tw Status: Open Bug Type: Zend Engine 2 problem Operating System: * PHP Version: 5CVS New Comment:
and this? Fatal error: Only variables or references can be returned by reference in /usr/lib/php/DB/common.php on line 766 function &query($query, $params = array()) { if (sizeof($params) > 0) { $sth = $this->prepare($query); if (DB::isError($sth)) { return $sth; } $ret = $this->execute($sth, $params); $this->freePrepared($sth); return $ret; } else { $result = $this->simpleQuery($query); if (DB::isError($result) || $result === DB_OK) { return $result; } else { -->766 return new DB_result($this, $result); } } } running on Apache/2.0.48 (Trustix Secure Linux/Linux) PHP/5.0.0b2 Previous Comments: ------------------------------------------------------------------------ [2003-11-17 02:35:55] mag at alcormizar dot cjb dot net I agree with Zeev on this one, this shouldn't be fixed. People will need to learn to write good code one day or the other, and returning a reference like that is VERY bad practice (try to do that in C++!). Even returning a reference to a local variable like this example should produce an error : class foo { function &bar() { $whatever = 5; return $whatever; } } because $whatever should not exist anymore after function bar return (according to correct scope rules), thus this reference is not referencing anything anymore... Instead of always asking to fix bad programming practice people should learn the correct way to do it. This is my opinion. ------------------------------------------------------------------------ [2003-11-13 14:28:05] [EMAIL PROTECTED] Reopening, as this is something that definitely can not pass. And Zeev mentioned that it's possible to fix. ------------------------------------------------------------------------ [2003-11-13 13:49:47] suren at qualys dot com There is no way this is a wontfix. Returning a function call is a common practice and a valid code. Please fix this bug as it breaks most of OOP based PHP scripts and there is no way people will migrate to php5 if it does not work. ------------------------------------------------------------------------ [2003-11-13 13:16:19] waboring at 3gstech dot com Fix your scripts? They weren't broken. php5 broke them. This is a very common thing to be able to do a return function_call_here() I'm ashamed at the comments against fixing this. Basically being..this is too hard, so you change instead. This is going to break a LOT of people's code and will prevent me from moving to php5. Please fix this. ------------------------------------------------------------------------ [2003-10-14 07:51:34] [EMAIL PROTECTED] Fix your scripts. ------------------------------------------------------------------------ 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/24687 -- Edit this bug report at http://bugs.php.net/?id=24687&edit=1