iam編寫一個php腳本,我希望該腳本執行,然後執行結果將被保存到另一個文件,然後它將重定向到該保存文件。在執行php腳本時回顯一個php代碼到html文件
我現在的問題是,IAM執行有一些PHP代碼,我需要保存,因爲它是在保存文件
<?php
function ago($time)
{
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
$periods[$j].= "s";
}
return "$difference $periods[$j] 'ago' ";
}
?>
IAM嘗試從執行的腳本呼應這些行腳本,使上述行可以保存。 和iam這樣做。
<?php
function rowFromVar($last_modified) {
$result = " <?php $$last_modified = filemtime(__FILE__);
function ago($time)
{
$periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
$lengths = array("60","60","24","7","4.35","12","10");
$now = time();
$difference = $now - $time;
$tense = "ago";
for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}
$difference = round($difference);
if($difference != 1) {
$periods[$j].= "s";
}
return "$difference $periods[$j] 'ago' ";
}
$last=ago($last_modified);";
return $result;
}
print rowFromVar("last_modified");
但亞姆有一些錯誤,如
(!) Parse error: syntax error, unexpected T_STRING in C:\wamp\www\SEO stat[Repica OF server]\Tools\domain_lookup1.php on line 109
任何幫助,將不勝感激。
檢查語法。您只是犯了一個小錯誤,請參閱代碼突出顯示它破壞的位置。 – hakre 2013-03-10 14:02:38
此外,nowdoc或heredoc字符串可能對您正在嘗試執行的操作更有用:http://php.net/string – hakre 2013-03-10 14:03:29