私は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
任意の助けをいただければ幸いです。