Set multiple includes folders with arrays for set_include_path and ini_set using PHP

January 18, 2024


$set_include_path_array['/home/includes/test/a'] = 'Description of folder a';
$set_include_path_array['/home/includes/test/b'] = 'Description of folder b';

foreach($set_include_path_array as $set_include_path_k => $set_include_path_v){
$includes_path_loop .= PATH_SEPARATOR . $set_include_path_k;
}

$includes_path = '.' . $includes_path_loop;

set_include_path($includes_path);
or
ini_set('include_path', $includes_path);

include('a.php'); // in the a folder
include('b.php'); // in the b folder
include('c.php'); // in the current folder


Comments

There are no comments.


Comment on this Article

Your email address will never be published. Comments are usually approved within an hour or two. (to prevent spam)