Three documents
r.php c.php 和 r/d.php
r.php
<?php require_once 'r/d.php'; echo 'sssss'; ?>
d.php
<?php require_once '../c.php'; echo 'dddddd'; echo '<br />' ?>
c.php
<?php echo 'cccccc'; echo '<br />' ?>
When performing r.php will error:
Warning: require_once(../c.php): failed to open stream: No such file or directory in D:\phpStudy\PHPTutorial\WWW\php\r\d.php on line 2
Fatal error: require_once(): Failed opening required '../c.php' (include_path='.;C:\php\pear') in D:\phpStudy\PHPTutorial\WWW\php\r\d.php on line 2
But when we direct execution is not being given d.php
Similar r.php here on the practical implementation of this:
? < PHP // require_once 'r / d.php'; // here is equivalent to the introduction of such require_once '../c.php'; // this is the case is the equivalent of r.php superiors find c.php echo 'DDDDDD' ; echo '<br />' echo 'sssss' ; ?>
You can combine dirname (dirname (__ FILE__)) using an absolute path