Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
描述一个php页面模板如何将另一个php页面编写为html_Php - Fatal编程技术网

描述一个php页面模板如何将另一个php页面编写为html

描述一个php页面模板如何将另一个php页面编写为html,php,Php,用PHP相关术语描述一个PHP/MYSQL页面a.PHP的机制,1使用一个模板编写自己的simple,2从用户那里获取输入以更新数据库simple,3根据命令解析另一个PHP页面B.PHP???并将B.php页面另存为静态HTML B.HTML UPDATE=我在这里找到了一篇帖子,向另一个呻吟的非优步极客提出了一个非常普通的问题,他可以使用输出缓冲区从php页面捕获html。这对不同的php文件有效吗?每个问题都有更复杂、更好的答案,但我会记下最简单的答案 PHP是一种模板语言,因此带有模板的

用PHP相关术语描述一个PHP/MYSQL页面a.PHP的机制,1使用一个模板编写自己的simple,2从用户那里获取输入以更新数据库simple,3根据命令解析另一个PHP页面B.PHP???并将B.php页面另存为静态HTML B.HTML


UPDATE=我在这里找到了一篇帖子,向另一个呻吟的非优步极客提出了一个非常普通的问题,他可以使用输出缓冲区从php页面捕获html。这对不同的php文件有效吗?

每个问题都有更复杂、更好的答案,但我会记下最简单的答案

PHP是一种模板语言,因此带有模板的PHP文件就是您的答案。这个问题有点模糊。 使用$\u GET或$\u POST superglobals访问用户提供的数据,其选择取决于您的HTTP请求方法。基本上,GET用于URL数据,POST用于表单数据。获得数据后,验证它。然后使用连接到数据库并执行插入查询。 您可以使用输出缓冲区,如下所示:
我被这个问题弄得心烦意乱,感到很难过。为了证明我的Q是真诚的,我用一个简单的解决方案来回答我自己的问题。我创建了generate.php,以便在对内容进行更改时运行。不需要缓存

// the switch...
$update_live = isset($_GET['update_live']) ? TRUE : FALSE;
// $adminPath, $livePath, $adminUrl are set in an include and contains site config data...
$tempfile = $adminPath . 'tempindex.html'; //a temp file...
$livefile = $livePath . 'index.html'; //the static live file...
$this_template = $adminUrl . 'main-index.php'; //the php template file...
$username = "php_admin";
$password = "123xyz456";

if(!($update_live)){
        $errors[] = "Did not submit from an edit page. You can only access this page by referral!";
}else{
        if(file_exists($tempfile)){
                unlink($tempfile);
        }
        /* =3, $html = file_get_contents($this_template, false, $context);*/
        $html = file_get_contents($this_template);
        if($html === false){
                $errors[] = "Unable to load template. Static page update aborted!";
                exit();
        }
        if(!file_put_contents($tempfile, $html)){
                $errors[] = "Unable to write $tempfile. Static page update aborted!";
                exit();
        }

        if(!copy($tempfile, $livefile)){
                $errors[] = "Unable to overwrite index file. Static page update aborted!";
                exit();
        }
        if(!unlink($tempfile)){
                $errors[] = "Unable to delete $tempfile. Static page update aborted!";
                exit();
        }
}

这是你的作业吗?是的,国际开源学校,宝贝!没有一个问题是愚蠢的。只有愚蠢的回答!我试图在写答案的时候考虑这是家庭作业的可能性。我希望答案能提供足够的信息,让有诚实意图的人走上正轨。2哈哈。好啊我明白你说的模糊是什么意思。我不是说,PHP是什么,它能为我做什么。我已经在用PHP3编程了,就这样!谢谢现在,我想再次让人不安,但是想象一下,您遇到了一个需要这个输出缓冲区解决方案的问题,您如何使用另一个PHP页面来描述PHP?如果在HTML页面中使用PHP包含函数,则可以模块化HTML页面的块。因此,我可能会搜索或使用术语将其描述为模块化、块、php html模板。再一次对不起,我只是想不起如何描述我的问题。有人想点击我的问题备份吗?这伤害了我的自尊PSS。看看我之前的问题,从来没有得到过op_缓冲区,还有另一个问题是PHPfreaks,
// the switch...
$update_live = isset($_GET['update_live']) ? TRUE : FALSE;
// $adminPath, $livePath, $adminUrl are set in an include and contains site config data...
$tempfile = $adminPath . 'tempindex.html'; //a temp file...
$livefile = $livePath . 'index.html'; //the static live file...
$this_template = $adminUrl . 'main-index.php'; //the php template file...
$username = "php_admin";
$password = "123xyz456";

if(!($update_live)){
        $errors[] = "Did not submit from an edit page. You can only access this page by referral!";
}else{
        if(file_exists($tempfile)){
                unlink($tempfile);
        }
        /* =3, $html = file_get_contents($this_template, false, $context);*/
        $html = file_get_contents($this_template);
        if($html === false){
                $errors[] = "Unable to load template. Static page update aborted!";
                exit();
        }
        if(!file_put_contents($tempfile, $html)){
                $errors[] = "Unable to write $tempfile. Static page update aborted!";
                exit();
        }

        if(!copy($tempfile, $livefile)){
                $errors[] = "Unable to overwrite index file. Static page update aborted!";
                exit();
        }
        if(!unlink($tempfile)){
                $errors[] = "Unable to delete $tempfile. Static page update aborted!";
                exit();
        }
}