|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-12-31 22:36 UTC] jani@php.net
-Status: Open
+Status: Wont fix
-Package: Feature/Change Request
+Package: *General Issues
[2010-12-31 22:36 UTC] jani@php.net
[2010-12-31 22:36 UTC] jani@php.net
-Package: *General Issues
+Package: Scripting Engine problem
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 13:00:02 2025 UTC |
It would be nice if a separate statement or function was used to exit include files, instead of re-using the "return" statement for this purpose. Take the following example. In test1.php say I have: <? include("./test2.php"); echo "Foo"; ?> And in test2.php I have: <? function croak ($msg) { echo $msg; return false; } mysql_connect(...) or croak("Can't connect"); mysql_select_db("foobar") or croak("Can't open DB"); ?> This doesn't work, of course. The return statement only returns from the function and the include file continues processing. One instead has to do something tedious like: <? if (!mysql_connect(...)) { echo "Can't connect"; return false; } if (!mysql_select_db(...)) { echo "Can't open DB"; return false; } ?> Hence I propose the addition of a new statement, which I will call "stop", which exits from the current include file. Then test2.php would look like: <? function croak ($msg) { echo $msg; stop; } mysql_connect(...) or croak("Can't connect"); mysql_select_db("foobar") or croak("Can't open DB"); ?> Just an idea :-)