我如何可以将使用HTML的根目录下,并链接到它之外的PHP脚本? [英] How can I place a PHP script outside the root directory and link to it using HTML?

查看:199
本文介绍了我如何可以将使用HTML的根目录下,并链接到它之外的PHP脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WAMP,我有两个目录; / www和/脚本。是/ www我的index.html,并在/脚本我有test.php的。我不是太熟悉标准PHP目录约定,但这里是我想在我的index.html文件是什么

I am using wamp, and I have two directories; /www and /scripts. In /www I have index.html, and in /scripts I have test.php. I am not too familiar with standard PHP directory conventions, but here is what I would like to have in my index.html file

...html statements...
<run the following php script: /scripts/test.php>
...html statements

而不是包含在index.html文件的PHP脚本本身。

rather than include the php script itself in the index.html file.

我已经研究了Apache的ScriptAlias​​指令(http://httpd.apache.org/docs/2.0/mod/mod_alias.html#scriptalias),但我不明白如何将其应用到这种情况。如何进行任何想法?

I have researched the ScriptAlias directive in Apache (http://httpd.apache.org/docs/2.0/mod/mod_alias.html#scriptalias) but I didn't quite understand how to apply it to this situation. Any ideas on how to proceed?

推荐答案

您无法链接从内部HTML文档根外PHP,但你可以包括来自文档根目录以外的PHP在PHP。即用的index.php替换的index.html,这看起来是这样的:

You can't link to PHP outside the doc root from within HTML, but you can include PHP from outside the doc root from within PHP. I.e., replace the index.html with an index.php, that looks something like this:

...html statements...
require_once '/path/to/scripts/test.php';
...html statements...

这篇关于我如何可以将使用HTML的根目录下,并链接到它之外的PHP脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆