Home > php教程 > php手册 > 保证include文件中的路径总是可用

保证include文件中的路径总是可用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:23:26
Original
1156 people have browsed it

这个是让人头疼的问题,我的解决办法是:使用绝对路径,并用 $MAIN_PATH 和 $Con_MAINPATH 两个变量保持其可移植性。
比如:


$Con_MAINPATH="http://lastleaf.51.net/cgi-bin";

$MAINPATH="/home/myweb/cgi-bin"

#include "$MAINPATH/php/showphp.php"; //调用别的文件。

//如果showphp.php中还要调用别的文件,
//则写成 "url=$Con_MAINPATH/php/title.gif" 。

?>

注意区分url和文件路径,比如:

$fp=fopen("$MAINPATH/files/a.htm","r");

echo "Click here";

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Explain what "limit" means?
From 1970-01-01 08:00:00
0
0
0
Error reported during verification
From 1970-01-01 08:00:00
0
0
0
Verification code, refresh failed
From 1970-01-01 08:00:00
0
0
0
Convert html files to word
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template