如何在我的计算机上运行 htdocs 目录之外的 PHP 文件? [英] How to run a PHP file on my computer that is outside the htdocs directory?

查看:21
本文介绍了如何在我的计算机上运行 htdocs 目录之外的 PHP 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在我的计算机上安装了 Apache 和 PHP,以便能够在本地运行 PHP 文件.

I just installed Apache and PHP on my computer to be able to run PHP files locally.

如果 PHP 文件位于 Apache2.2\htdocs 目录中,我可以运行它.

I can run a PHP file if it is located in Apache2.2\htdocs directory.

是否可以在此目录外运行 PHP 文件?

Is that possible to run PHP files outside this directory ?

我正在寻找一个简单的解决方案,因为我所需要的只是编写一个小的 PHP 代码并在本地进行尝试.

I'm looking to a simple solution, because all I need is to write a small PHP code and try it locally.

我希望能够通过右键单击 PHP 文件来运行它 -> 使用 Firefox 打开

I would like to be able to run the PHP file by right clicking it -> Open with Firefox

推荐答案

有一些方法可以做到,但最简单的方法是使用 'include' 或 'required' php 命令:

There is some ways to do it, but the simplest way is using 'include' or 'required' php command:

<?
include ('/somewhere/outside/of/your/htdocs/file.php');
?>

请注意,您可能需要关闭 'open_basedir' php 指令.

Please note you may need to turn off 'open_basedir' php directive.

这篇关于如何在我的计算机上运行 htdocs 目录之外的 PHP 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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