使用包含()的相对路径 [英] Using Relative Paths With include()

查看:66
本文介绍了使用包含()的相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在玩一些PHP代码。我想输入一个include()

函数,这样我就可以包含现有的HTML代码并将其输出到浏览器。


Lo并且看来PHP没有使用include()

函数支持相对路径! (你有多短视?)有没有办法用include()来使用

相对路径?任何黑客?如果我使用绝对文件路径,

一切都很好。但我不想那样做 - 我不能那样做。我希望

使用相对于当前正在执行的PHP文件的文件路径。


在某处我读到了一些关于使用.htaccess文件和放置
的内容
里面会添加一个包含的内容对于HTML文件我想要

包括我不必更改php.ini(无论如何我都无法访问生产服务器上的php.ini

。 )。这样我就可以把它放在我的

webroot目录中,一切都会好的。


帮助将不胜感激。


谢谢。

I am playing around with some PHP code. I want to put in an include()
function so I can include existing HTML code and output it to the browser.

Lo and behold PHP does not support relative paths with the include()
function! (How shortsighted can you get?) Is there any way at all to use
relative paths with include()? Any hacks? If I use an absolute filepath,
everything is fine. But I don''t want to do that--I can''t do that. I want
to use the filepath relative to the currently executing PHP file.

Somewhere I read something about using an .htaccess file and putting
something in it that will add an "include" for the HTML file I want to
include without me having to change php.ini (I won''t have access to php.ini
on the production server anyway.). That way I could just drop it in my
webroot directory and everything would be fine.

Help will be appreciated.

Thanks.

推荐答案

MBS写道:
我正在玩一些PHP代码。我想放入一个include()
函数,这样我就可以包含现有的HTML代码并将其输出到
浏览器。

看到PHP不支持相对路径include()
函数!
I am playing around with some PHP code. I want to put in an include()
function so I can include existing HTML code and output it to the
browser.

Lo and behold PHP does not support relative paths with the include()
function!




它确实在PHP4和PHP5中完美运行。

搜索代码中的错误。


Grtz,

Rik



It does, works perfectly here in PHP4 and PHP5.
Search your code for errors.

Grtz,

Rik


" Rik" <卢************ @ hotmail.com>在新闻中写道:dlf7km
"Rik" <lu************@hotmail.com> wrote in news:dlf7km


6fa


这篇关于使用包含()的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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