#37047 [Ver->Opn]: static executes after return

From: Date: Mon, 20 Aug 2007 10:42:40 +0000
Subject: #37047 [Ver->Opn]: static executes after return
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-116351@lists.php.net to get a copy of this message
ID: 37047 Updated by: vrana@php.net Reported By: karoly at negyesi dot net -Status: Verified +Status: Open -Bug Type: Documentation problem +Bug Type: Variables related Operating System: Irrevelant PHP Version: 5.1.2 New Comment: If static variables are resolved in compile time then <?php function storage($key) { return $storage; static $storage = array('a' => array('x', 'y')); } var_dump(storage('a')); ?> should give an expected result. Previous Comments: ------------------------------------------------------------------------ [2006-04-12 08:31:01] tony2001@php.net It's the same as <?php exit; class Test { } ?> The class will be still declared, even though there is an exit statement before the declaration. It doesn't mean that it's "executed", because there is a big difference between "execution" and "compilation". ------------------------------------------------------------------------ [2006-04-11 22:44:27] karoly at negyesi dot net Hint. If you doc this please doc everything as well that executes at compile time. It will be a very interesting handbook page... ------------------------------------------------------------------------ [2006-04-11 22:38:31] sean@php.net Sorry. I misread. You're right (-: S ------------------------------------------------------------------------ [2006-04-11 22:37:29] sean@php.net see: http://php.net/return "the return() statement immediately ends execution of the current function" (It's already documented.) S ------------------------------------------------------------------------ [2006-04-11 22:28:04] karoly at negyesi dot net Then this is a docs issue. Because I do not expect anything to be executed after a return... ------------------------------------------------------------------------ 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/37047 -- Edit this bug report at http://bugs.php.net/?id=37047&edit=1

« previous php.bugs (#116351) next »