ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> phpdoc
phpdoc
[PHP-DOC] #37047 [Ver]: static executes after return
by Karoly At Negyesi Dot Net other posts by this author
Apr 11 2006 3:44PM messages near this date
Re: [PHP-DOC] Typo in localtime() example | [PHP-DOC] #37047 [Ver]: static executes after return
ID:               37047
 User updated by:  karoly at negyesi dot net
 Reported By:      karoly at negyesi dot net
 Status:           Verified
 Bug Type:         Documentation problem
 Operating System: Irrevelant
 PHP Version:      5.1.2
 New Comment:

Hint. If you doc this please doc everything as well that executes at
compile time. It will be a very interesting handbook page...


Previous Comments:
------------------------------------------------------------------------

[2006-04-11 22:38:31] sean@[...].net

Sorry. I misread.

You're right (-:

S


------------------------------------------------------------------------

[2006-04-11 22:37:29] sean@[...].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...

------------------------------------------------------------------------

[2006-04-11 22:21:31] tony2001@[...].net

Static variables are resolved in compile time.
Expected behaviour.

------------------------------------------------------------------------

[2006-04-11 22:15:50] karoly at negyesi dot net

Description:
------------
The code has been tested on PHP 4.3, 4.4, 5.0 and 5.1 various minors.

Reproduce code:
---------------
function storage($key) {
  static $storage = array('a' =>  array('x', 'y'));
  return $storage[$key];
  static $storage = array('x', 'y'); // comment this out to see
expected result
}
var_dump(storage('a'));

Expected result:
----------------
array(2) {
  [0]=> 
  string(1) "x"
  [1]=> 
  string(1) "y"
}


Actual result:
--------------
NULL


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=37047&edit=1
Thread:
Karoly At Negyesi Dot Net
tony2001

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved