PHP 如何在 PHP 中执行其他文件扩展名?
我正在尝试找到设置,让 PHP 在 PHP 引擎中执行其他文件扩展名?
有什么想法吗?
Iam trying to find the setting, where i can have PHP execute other file extensions into the PHP Engine?
Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
exec()
将执行外部程序,如果这就是您的意思。您可以捕获输出,但我不确定这是否就是您所说的“进入 PHP 引擎”的意思。http://php.net/manual/en/function.exec.php
编辑:如果您的意思是像 PHP 一样运行其他文件扩展名,您可以编辑 .htaccess 来指定文件类型。例如,要将 .html 作为 PHP 运行:
exec()
will execute an external program, if that's what you mean. You can capture the output, but I'm not sure if that's what you mean by "into the PHP engine."http://php.net/manual/en/function.exec.php
Edit: If you mean running other file extensions as PHP, you can edit .htaccess to specify the file type. For example, to run .html as PHP:
这与您的服务器处理请求的方式有关。服务器可能配置为将带有 .php 扩展名的请求传递给 php。您可以修改服务器配置以将其他请求传递给 php 解析器。
由于我不知道你使用什么类型的服务器,所以我不能说如何修改配置。
This would have to do with how your server handles requests. The server if probably configured to pass requests with the .php extension to php. You could modify your server configuration to pass other requests to the php parser as well.
Since I don't know what type of server you're using, I can't say how to modify the config.
您可以使用 include 函数执行其他文件。这会将任何带有 php 标签的文件解析为 php!
**注意 - 包含来自 webroot 的非 php 文件意味着人们可以访问相关脚本,而无需执行该脚本。我强烈建议您在大多数情况下不要这样做。
You can execute other files using the include function. This will parse any file with the php tags into php!
**NOTE - Including files from the webroot that are non-php means that people can gain access to the script in question, without it being executed. I highly Recommend that you don't do this in most situations.