note 93901 added to function.include

From: Date: Tue, 06 Oct 2009 01:43:38 +0000
Subject: note 93901 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-161386@lists.php.net to get a copy of this message
here's another way to include your files. <?php function includeFile($file_name){ $dir = array('./', 'lib/', 'db/', 'student/'); //<-- put here your website directory you want to include $level = array('', '/', '../', '../../'); //<-- you can add more deep level in this array $ini_path = array(); foreach($dir as $p){ foreach($level as $l){ $file = $l.$p.$file_name; if(file_exists($file)){ include_once($file); return; } } } } //end function includeFile includeFile('html.php'); includeFile('libpage.php'); ?> ---- Server IP: 202.89.58.1 Probable Submitter: 210.54.120.42 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- https://master.php.net/note/edit/93901 Del: integrated -- https://master.php.net/note/delete/93901/integrated Del: useless -- https://master.php.net/note/delete/93901/useless Del: bad code -- https://master.php.net/note/delete/93901/bad+code Del: spam -- https://master.php.net/note/delete/93901/spam Del: non-english -- https://master.php.net/note/delete/93901/non-english Del: in docs -- https://master.php.net/note/delete/93901/in+docs Del: other reasons-- https://master.php.net/note/delete/93901 Reject -- https://master.php.net/note/reject/93901 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161386) next »