I learn zephir with documentation, I meet trouble with 'empty' function. The problem as follows:
public function testEmpty()->void
{
let someVar = 0;
if empty someVar {
echo "is empty!";
}
}
When I use 'zephir build', it appears:
Zephir\CompilerException: Cannot mutate variable 'someVar' because it wasn't defined in /root/utils/utils/filter.zep on line 20
let someVar = 0;
But when I modify my code as follows:
public function testEmpty()->void
{
var someVar;
let someVar = "";
echo "\n" . typeof(someVar) . "\n";
let someVar = 0;
echo typeof(someVar) . "\n";
if empty someVar {
echo "is empty!";
}
}
Then use 'zephir build' command, it becames ok as follows:
[[email protected] utils]# zephir build
Compiling...
Installing...
Extension installed!
Don't forget to restart your web server
So, Why appear this problem? Anyone can help me? Thank you!