Different OS and Server Path
in windows (using apache as server), my file path directory will be C:\xampp\htdocs\mysvn\PhpDocumentor\phpdoc.php. But what happen with other OS such as linux on APACHE, or IIS on windows, Or other OS i don't know and never use ?
i would like t开发者_如何学运维o know to make sure i wrote the bullet proof, file reading via PHP.
Care anyone give an example path according to different OS and Server ?
I often create a configuration file for each project, and inside that define some paths in a few constants. Use those constants any time you want to include files from then on:
// config.php
define('ROOT', dirname(__FILE__));
define('LIBS', ROOT . '/libs');
// some other file.php
include LIBS . '/mylib.php';
Though Windows typically uses backslashes as path separators, it's smart enough to handle both, so using forward slashes is safe.
精彩评论