如何在我的计算机上运行 htdocs 目录之外的 PHP 文件?

编程入门 行业动态 更新时间:2024-10-24 10:22:24
本文介绍了如何在我的计算机上运行 htdocs 目录之外的 PHP 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我刚刚在我的计算机上安装了 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-20 00:23:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/972795.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:机上   文件   目录   如何在   htdocs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!