As of writing this note (PHP 5.3.1) serialization of closure is not allowed.
This means a code like the one below:
<?php
$bar3 = function($a) {
return $a * 2;
};
wincache_ucache_set('foo3', $bar3);
var_dump(wincache_ucache_get('foo3'));
echo "<br>";
?>
Will throw exception:
[11-Feb-2010 09:25:33] PHP Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in C:\inetpub\wwwroot\phptest\tests\ucache\wincache15.php:6
Stack trace:
#0 C:\inetpub\wwwroot\phptest\tests\ucache\wincache15.php(6): wincache_ucache_set('foo3', Object(Closure))
#1 {main}
thrown in C:\inetpub\wwwroot\phptest\tests\ucache\wincache15.php on line 6
However one catch this exception like:
<?php
$bar3 = function($a) {
return $a * 2;
};
try
{
wincache_ucache_set('foo3', $bar3);
}
catch (Exception $e)
{
var_dump($e->getMessage());
}
var_dump(wincache_ucache_get('foo3'));
echo "<br>";
?>
This will generate output as shown beloe:
string(41) "Serialization of 'Closure' is not allowed" NULL