我如何允许PHP运行时,脚本不在URL


How do I allow PHP to run when the script is not in the URL?

我想得到一个PHP脚本运行时,我去我的网站的某个文件夹,但不让它在URL中显示。

我希望/number/number.php在用户访问/number/

时运行

我需要使用。htaccess文件来做到这一点吗?

您可以尝试在这个文件夹上创建一个index.php文件,并使用include语句来包含number.php。到目前为止,每次在URL上键入文件夹时,服务器都会搜索要运行的索引文件,而index.php不包含在URL中。

如果你想让一个脚本在没有用户访问该页面的情况下运行…您可以简单地将该文件包含在另一个文件中。例如,您可以在/number/文件夹中创建index.php,其中包含以下代码:

<?php
include("./numbers.php"); /* the './' means, it refers to the same folder */
?>