there's another question is as follows that about 'empty' function in zephir. The code is:
public function testEmpty()->void
{
var someVar;
let someVar = 0;
echo typeof(someVar) . "\n";
if empty someVar {
echo "is empty!";
}
}
When I use 'zephir build' command, it appears this:
[[email protected] utils]# zephir build
Zephir\CompilerException: Only dynamic/string variables can be used in 'empty' operators in /root/utils/utils/filter.zep on line 23
if empty someVar {
-------------------------^
Then, I modify code as follows:
public function testEmpty()->void
{
// var someVar;
// let someVar = 0;
// echo typeof(someVar) . "\n";
// if empty someVar {
// echo "is empty!";
// }
var someVar;
let someVar = "";
echo "\n" . typeof(someVar) . "\n";
let someVar = 0;
echo typeof(someVar) . "\n";
if empty someVar {
echo "is empty!";
}
}
buid again:
[[email protected] utils]# zephir build Compiling... Installing... Extension installed! Don't forget to restart your web server
This time is OK. so the test result as follows:
[[email protected] utils]# php example/test.php
string
integer
is empty!
So, my question is why first condition code build failure? In the second condition just assign string to varablie beofore assign 0 to it, Thanks.