警告:substr()期望参数2很长

时间:2013-03-01 06:32:47

标签: php string web-scraping substr

为什么我在使用substr时收到此错误:

  

警告:substr()期望参数2为long`

$url = "http://coast.x-matic.net/forums/categories/pso-news";

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$webdata = (string) curl_exec($ch); 
curl_close($ch);

echo substr($webdata, "<a * class=\"title\">*</a>"); 

1 个答案:

答案 0 :(得分:0)

参考:http://php.net/manual/en/function.substr.php

substr:string substr ( string $string , int $start [, int $length ] )

的语法

echo substr($webdata, 0, 5);应该是这样的。