PHP Include with Source From Different Directory

By: PowAxx | December 9, 2009 at 3:18 am | Posted in Web Design
About: Having a different directory for calling a PHP file may cause a “PHP Warning: include() [function.include]” if syntax was not correctly included.

These codes will let you include a PHP file located on a different directory. It will prevent the errors in “function.include”

If the included file is one level higher than the web page with the inclusion directive you can use:
<?php include (‘../header.php’); ?>

and if it’s two levels higher:
<?php include(‘../../header.php’); ?>

Leave Comment