php include 路径问题的解决方案

大家都知道,A包含B时必须包含B的绝对路径,才不会因为A的位置改变而导致错误。

那么绝对路径怎么来?有个人给出的方法不错:

在每个php的文件开头写上:

<?php set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); 
?>

Now anywhere you do an include you can do something like:

<?php include ( "Templates/header.inc") ?>

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.