Home >Backend Development >PHP Tutorial >Ensure that paths in include files are always available_PHP Tutorial

Ensure that paths in include files are always available_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 17:23:23957browse

This is a headache, and my solution is to use absolute paths and keep it portable with $MAIN_PATH and $Con_MAINPATH variables.
For example:


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

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

#include "$MAINPATH/php/showphp.php"; //Call other files.

//If showphp.php also calls other files,
//Write "url=$Con_MAINPATH/php/title.gif".

?>

Pay attention to distinguish url and file path, for example:

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

echo "Click here";

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532230.htmlTechArticleThis is a headache. My solution is: use absolute paths and use $MAIN_PATH and $Con_MAINPATH Both variables maintain their portability. For example: $Con_MAINPATH="http...
Statement:
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