开发者

Different OS and Server Path

开发者 https://www.devze.com 2022-12-23 16:31 出处:网络
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 ot

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号