|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-06-10 13:53 UTC] neto dot joaobatista at gmail dot com
Description:
------------
NULL when using Closures with "use" keyword in PHP 5.3.2
Test script:
---------------
<?php
$test = 'Closure test';
$closure = function() use ( $test ) { return $test; };
var_dump( phpversion() , $closure );
Expected result:
----------------
PHP 5.3.0 output:
string(5) "5.3.0"
object(Closure)#1 (1) {
["static"]=>
array(1) {
["test"]=>
string(12) "Closure test"
}
}
Actual result:
--------------
PHP 5.3.2 output:
string(5) "5.3.2"
NULL
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 07:00:01 2025 UTC |
New information, PHP: 5.3.0, 5.3.2 and 5.3.3 works fine as CLI Output from 5.3.3 string(9) "5.3.3-dev" object(Closure)#1 (1) { ["static"]=> array(1) { ["test"]=> string(12) "Closure test" } } Using PHP 5.3.3-dev as CGI works too: string(9) "5.3.3-dev" object(Closure)#1 (1) { ["static"]=> array(1) { ["test"]=> string(12) "Closure test" } } I just couldn't test 5.3.3-dev as Apache module yet, but 5.3.2 doesn't work as module, giving me: string(5) "5.3.2" NULL Server Version: Apache/2.2.15 (Unix) DAV/2 PHP/5.3.2 mod_python/3.3.1 Python/2.6.4 mod_ssl/2.2.15 OpenSSL/1.0.0-fips mod_perl/2.0.4 Perl/v5.10.1