Why doesn't this work:
echo (function() {
if (strlen($_POST["a"]) > 150) {
return "123";
}
return "abc";
})();
is there anyway to do this in PHP?
Like in JS you can do:
var x = (function() {return "asd";})();
Why doesn't this work:
echo (function() {
if (strlen($_POST["a"]) > 150) {
return "123";
}
return "abc";
})();
is there anyway to do this in PHP?
Like in JS you can do:
var x = (function() {return "asd";})();
You can do this, just not with the elegant syntax of Javascript. You need call_user_func
:
echo call_user_func(function() {
if (strlen($_POST["a"]) > 150) {
return "123";
}
return "abc";
});