Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 警告:在。。。在线133_Php_Divide By Zero - Fatal编程技术网

Php 警告:在。。。在线133

Php 警告:在。。。在线133,php,divide-by-zero,Php,Divide By Zero,基本上,我制作了一个脚本,可以登录到一个网站,从该网站获取元素,然后将一个元素与另一个元素分开。问题是,我已经检查了很多次,除数不是零。以下是片段: if($num==0) { echo "<td>".$estate_income."/".$num."</td>"; } else { echo "<td>".$estate_income/$num."<

基本上,我制作了一个脚本,可以登录到一个网站,从该网站获取元素,然后将一个元素与另一个元素分开。问题是,我已经检查了很多次,除数不是零。以下是片段:

if($num==0)
{
    echo "<td>".$estate_income."/".$num."</td>";
}
else
{
    echo "<td>".$estate_income/$num."</td>";
}
我现在要问的是,为了找到一个解决方案,也许有一些错误检测方法可以告诉我我做错了什么。这可能是我忽略的一件非常明显的事情

提前谢谢

艾哈迈德·阿尔巴亚蒂

编辑:
发现了问题。正如我已经提到的,我从一个网站上获得了这些值。当我在字符串上使用var_dumb时,它输出
string(149)“202000”
。这实际上让我很困惑,因为字符串/数字只有6个字符。所以我决定看看源代码,我发现:

<spanstyle="white-space:nowrap;"><imgsrc="http: staticstorm8com="" vl="" images="" bloodpng?v="330&quot;width=&quot;9&quot;height=&quot;12&quot;style=&quot;padding-right:2px&quot;">202000<br></imgsrc="http:></spanstyle="white-space:nowrap;">

202000
你能构造一个演示这个问题的方法吗?@AycanYaş305; t如果我尝试去定义它,我会得到错误
If(intval($num)==0)
发布你的剩余代码,特别是在你定义
$num
的地方。请停止发布大型程序的随机部分,而是发布一个。您应该已经构建了一个,以进行自己的调试。这说明你显然没有。有一些操作员,这样可以让你只抓取文本。例如,在Perl中。(就像我给你看的脚本一样),你可以使用:[^>]*>([^Lol,谢谢xD。但是我使用的是strip_标签,非常好用!谢谢你的评论。
            try
            {
                echo "<td>".$estate_income/$num."</td>";
            }
            catch(Exception $e)
            {
                echo 'Caught exception: ',  $e->getMessage(), "\n";
            }
function num_format($n)
{
    $n=str_replace(",","",str_replace(" ","",$n));
    if(strpos($n,".")===FALSE)
    {
        if(strpos($n,"K")!==FALSE)
        {
            $n=str_replace("$","",str_replace("K","000",$n));
        }
        elseif(strpos($n,"mil")!==FALSE)
        {
            $n=str_replace("$","",str_replace("mil","000000",$n));
        }
        elseif(strpos($n,"bil")!==FALSE)
        {
            $n=str_replace("$","",str_replace("bil","000000000",$n));
        }
        elseif(strpos($n,"tril")!==FALSE)
        {
            $n=str_replace("$","",str_replace("tril","000000000000",$n));
        }
        else
        {
            $n=str_replace("$","",$n);
        }
    }
    else
    {
        $n=str_replace(".","",$n);
        if(strpos($n,"K")!==FALSE)
        {
            $n=str_replace("$","",str_replace("K","00",$n));
        }
        elseif(strpos($n,"mil")!==FALSE)
        {
            $n=str_replace("$","",str_replace("mil","00000",$n));
        }
        elseif(strpos($n,"bil")!==FALSE)
        {
            $n=str_replace("$","",str_replace("bil","00000000",$n));
        }
        elseif(strpos($n,"tril")!==FALSE)
        {
            $n=str_replace("$","",str_replace("tril","00000000000",$n));
        }
        else
        {
            $n=str_replace("$","",$n);
        }
    }
    global $num;
    $num=$n;
}
<spanstyle="white-space:nowrap;"><imgsrc="http: staticstorm8com="" vl="" images="" bloodpng?v="330&quot;width=&quot;9&quot;height=&quot;12&quot;style=&quot;padding-right:2px&quot;">202000<br></imgsrc="http:></spanstyle="white-space:nowrap;">