为何这段代码在本机调试时出错apache错误信息~说是执行了非法操作~但上传至服务器之后就能解释
function get_microtime()
{
list($usec,$sec)=explode(" ",microtime());
return ((double)$usec+(double)$sec);
}
function str_rev($str)
{
//$cnt++;
if(strlen($str)==1)
return $str;
$local_str=substr($str,strlen($str)-1,1);
$local_str=$local_str . str_rev(substr($str,0,strlen($str)-1));
return $local_str;
}
$teststr="";
for($i=0;$i<25;$i++)
{
$teststr.="This is a string!";
}
//print("
".$teststr);
//Benchmark native PHP string reversal
$start_time=get_microtime();
$test=strrev($teststr);
$end_time=get_microtime();
//print($test);
$native_time=round((float)(($end_time-$start_tme)*1000),2);
print("
Native processing time:{$native_time}ms
");
//Benchmark recursive custom string reversal
$start_time=get_microtime();
$test=str_rev($teststr);
$end_time=get_microtime();
$recurse_time=round((float)(($end_time-$start_time)*1000),2);
print("Custom function pricessint time:{$recurse_time}ms
");
$speed_factor=$recurse_time/$native_time;
print("Navite string reversal is approximately ".$speed_factor." quicker.");
//print($test);
服务器文件:
http://www.fs123.com/4list2.php$test=str_rev($teststr);
是执行该表达式是就会出现~~~删掉就没问题~~但上传至服务器就没有错误信息~~~
是不是php.ini或apache还没设置好~~