Which one is correct to use for DIRECTORY_SEPARATOR?

I have another code which is similar to my existing code but I am thinking the found code works same or it is something different than my other code.


/ add all above directories to the include path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(ROOT_PATH.DS.CLASSES_DIR),
    realpath(ROOT_PATH.DS.PAGES_DIR),
    realpath(ROOT_PATH.DS.TEMPLATE_DIR),
    get_include_path()
)));

**My code:**

set_include_path(implode(PATH_SEPARATOR, 
		[ __DIR__.DIRECTORY SEPERATOR.'includes', get_include_path() ] ));

Kindly help? :shifty:

don’t use set_include_path() at all. use absolute paths at all times. if you’re including a file you are supposed to know exactly where it can be found, otherwise you will be in for some unexpected surprises.

for loading classes use an autoloader, and the template directory should only be configured with the template engine.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.