note 85112 added to function.return

From: Date: Fri, 15 Aug 2008 08:40:24 +0000
Subject: note 85112 added to function.return
Groups: php.notes 
Request: Send a blank email to php-notes+get-143517@lists.php.net to get a copy of this message
Response to stoic's message below... I believe the way you've explained this for people may be a bit confusing, and your verbiage is incorrect. Your script below is technically calling return from a global scope, but as it says right after that in the description above... "If the current script file was include()ed or require()ed, then control is passed back to the calling file". You are in a included file. Just making sure that is clear. Now, the way php works is before it executes actual code it does what you call "processing" is really just a syntax check. It does this every time per-file that is included before executing that file. This is a GOOD feature, as it makes sure not to run any part of non-functional code. What your example might have also said... is that in doing this syntax check it does not execute code, merely runs through your file (or include) checking for syntax errors before execution. To show that, you should put the echo "b"; and echo "a"; at the start of each file. This will show that "b" is echoed once, and then "a" is echoed only once, because the first time it syntax checked a.php, it was ok. But the second time the syntax check failed and thus it was not executed again and terminated execution of the application due to a syntax error. Just something to help clarify what you have stated in your comments. ---- Server IP: 208.69.120.35 Probable Submitter: 68.79.169.76 ---- Manual Page -- http://www.php.net/manual/en/function.return.php Edit -- https://master.php.net/note/edit/85112 Del: integrated -- https://master.php.net/note/delete/85112/integrated Del: useless -- https://master.php.net/note/delete/85112/useless Del: bad code -- https://master.php.net/note/delete/85112/bad+code Del: spam -- https://master.php.net/note/delete/85112/spam Del: non-english -- https://master.php.net/note/delete/85112/non-english Del: in docs -- https://master.php.net/note/delete/85112/in+docs Del: other reasons-- https://master.php.net/note/delete/85112 Reject -- https://master.php.net/note/reject/85112 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143517) next »