我正在编写一个 php 脚本,我希望该脚本执行,然后执行的结果将保存到另一个文件,然后它将重定向到该保存文件。
现在我的问题是我正在执行的脚本有一些我需要保存的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' ";
}
?>
我试图从执行脚本中回显这些行,以便可以保存上述行。我正在这样做。
<?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
任何帮助,将不胜感激 。