Answer the question
In order to leave comments, you need to log in
Storing a function inside a php session?
Next code:
$_SESSION['test'] = function(){
echo 'test';
};
Fatal error: Exception thrown without a stack frame in Unknown on line 0
Answer the question
In order to leave comments, you need to log in
Solved thanks to @LastDragon
Out of the box - nothing, but you can see (did not use it myself) PHP Super Closure ("a library that allows you to serialize closures in PHP", found in one of the digests ).
Weird:
php > $func = function() { echo 'test'; };
php > $func();
test
php > session_start();
php > var_dump($_SESSION);
array(0) {
}
php > $_SESSION['test'] = $func;
php > $_SESSION['test']();
test
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question