我在 CakePHP 中遇到以下错误,该函数在 PHP 中运行良好,但在 Cake 中运行不正常,有人知道为什么不支持或有解决方法吗?
Error: Unsupported operand types
File: /var/www/spitdev/console2/app/Lib/IpLib.php
Line: 40
Notice: If you want to customize this error message, create app/View/Errors/fatal_error.ctp
功能:
public function lastHost($ip_add, $subnet_mask){
$ip = ip2long($ip_add);
$nm = ip2long($subnet_mask);
$nw = ($ip & $nm);
$bc = $nw | (~$nm); <------------LINE 40
$lh = long2ip($bc - 1);
return $lh;
}
最佳答案
这不是操作数的问题,而是值传递的问题。确保 $ip_add 和 $subnet_mask 获得有效值而不是空值。 因为
$test=$this->lastHost('69.89.31.226','255.0.0.0');
var_dump($test);
返回有效结果而
$test_again=$this->lastHost('','');
var_dump($test_again);
返回与您指定的相同的错误
关于php - CakePHP 不支持的操作数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30527169/