我正在尝试从另一个站点获取内容。以下是php代码。但是当我运行它时,它会显示错误消息。
错误信息:
Parse error: syntax error, unexpected '–' (T_STRING) in D:\Software\Installed\xampp\htdocs
\test\index.php on line 10
php代码:
<?php
function get_string_between($string, $start, $end)
{
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0)
return "";
$ini += strlen($start);
$len = strpos($string, $end, $ini) – $ini; // this is line number 10.
return substr($string,$ini,$len);
}
//Initialize the Curl session
$ch = curl_init();
//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//Set the URL
curl_setopt($ch, CURLOPT_URL,"http://www.test.org/");
//Execute the fetch
$data = curl_exec($ch);
echo $da=get_string_between($data,'imgs/topdown.gif">','imgs/topdown.gif');
//Close the connection
curl_close($ch);
?>