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

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

问题描述

我刚刚安装在我的电脑上的Apache和PHP是能够运行PHP文件在本地。

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

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

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 code,并尝试在本地。

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

推荐答案

有一些方法可以做到这一点,但最简单的方法是使用'包括'或'需要'的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.

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

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