Re: #49346 [Bgs]: using return() with an empty argument list is causing in a parser error
| From: | Mark Skilbeck | Date: | Thu, 03 Sep 2009 19:45:46 +0000 |
| Subject: | Re: #49346 [Bgs]: using return() with an empty argument list is causing in a parser error | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45477@lists.php.net to get a copy of this message | ||
mirko dot steiner at slashdevslashnull dot de wrote:
echo is a language construct also, no?ID: 49346User updated by: mirko dot steiner at slashdevslashnull dot deReported By: mirko dot steiner at slashdevslashnull dot de Status: Bogus Bug Type: Reproducible crashOperating System: linux, freebsdPHP Version: 5.2.10New Comment: thank you, for your immidiatly response. yes, i know that ,,return'' is a language construct. it is documented that the parentheses are not required (1) but not that it is necessary that there have to be an argument if the parantheses are used. using ,,echo()'' for example, which is a function(!), brings the same parser error when using empty parentheses. it seems like an error in the parser where functions or ,,language constructs'' where the parantheses are optional. (1) http://de2.php.net/manual/en/function.return.php (requested Mon Aug 24 20:45:38 CEST 2009) Previous Comments: ------------------------------------------------------------------------ [2009-08-24 18:08:34] sjoerd@php.net Thank you for your report. The behavior you report is not a bug. You call return as if it is a function. It is not, it is a language construct. The correct syntax is: return 'bar'; or return; The parenthesis are not needed. ------------------------------------------------------------------------ [2009-08-24 15:20:57] mirko dot steiner at slashdevslashnull dot de Description: ------------ using return() with an empty argument list is causing in a parser error. Reproduce code: --------------- <?php function foo($arg) {if($arg) { return('bar'); } else { return(); }} ?> Expected result: ---------------- no parser error :-) Actual result: -------------- Parse error: syntax error, unexpected ')' in /usr/local/www/develop/htdocs/test.php on line 6 ------------------------------------------------------------------------