|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-08-28 14:10 UTC] + at ni-po dot com
Description: ------------ One thing that very much annoys me about the PHP documentation that it teaches beginners *wrong* stuff by writing all language constructs with parenthesis. Example: If called from within a function, the return() statement immediately ends execution of the current function [...] And it's like this everywhere! Admittedly all code examples use the correct syntax without parentheses. But writing return() everywhere else in the documentation makes it seem like the parentheses belong to the return statement and the syntax without parenthesis is only another way to write it. Thus I would strongly support the removal of this misleading notation. (This obviously doesn't apply only to the return statement, but to echo, print, include, include_once, require and require_once, too.) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 10:00:02 2025 UTC |
@markskillbeck: If I wrote #define min(X, Y) X < Y ? X : Y in C instead of #define min(X, Y) ((X) < (Y) ? (X) : (Y)) would you say it was wrong? I would. It may be syntactically correct, it may compile, but it doesn't make it correct. It's same with the parenthesis in PHP. Writing if (include('file.php') == true) is correct syntax, but it is logically wrong. The parenthesis create the feeling of a function.There is nothing wrong with ... if (include('file.php') == true) when file.php returns true or false upon inclusion. Perfectly valid.@rquadling: See, that's exactly the problem. Even a senior PHP developer will be tricked into thinking that the return value of the include is compared. But PHP evaluated this as: if (include ('file.php' == true)) This clearly shows that it's no good to write language constructs with parenthesis in the manual.