V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hwhtj
V2EX  ›  PHP

求助: PHP 错误,请高手帮我改写下面的 PHP 代码

  •  
  •   hwhtj · 4 小时 14 分钟前 · 124 次点击

    `<?php

    $nowtime=time();

    $pastsec = $nowtime - $_GET["t"];

    if($pastsec<600) { exit; //10 分钟更新一次,时间可以自己调整 } ob_start(); //打开缓冲区 include("index.php"); $content = ob_get_contents(); //得到缓冲区的内容 $content .= "\n<script language=javascript src='/index/thumb.png' data-original="html.php?t=".$nowtime.""></script>"; //加上调用更新程序的代码

    file_put_contents("index.html",$content); if (!function_exists("file_put_contents")) { function file_put_contents($fn,$fs) { $fp=fopen($fn,"w+"); fputs($fp,$fs); fclose($fp);
    } } ?>`

    以上代码用于生成 typecho 首页 index.html ,运行时提示错误: Warning: Undefined array key "t" in /www/onlineps.top/learn/html.php on line 3 求助高手帮我改写以上代码。

    1 条回复
    ejin
        1
    ejin  
       3 小时 28 分钟前
    前面改成这样

    <?php
    if(isset($_GET["t"]) ===false){
    die();
    }
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1183 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 17:37 · PVG 01:37 · LAX 10:37 · JFK 13:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.