johnmerlino Posted January 7, 2011 Share Posted January 7, 2011 Hey all, It's easy to look at documentation and see what each of these functions and that super global do individually. But I'm not sure how the three are working together here: define('APPLICATION_PATH', realpath('../')); $paths = array( APPLICATION_PATH, get_include_path() ); set_include_path(implode(PATH_SEPARATOR, $paths)); Thanks for response. Quote Link to comment https://forums.phpfreaks.com/topic/223715-how-set_include_path-and-implode-and-path_separator-work-together/ Share on other sites More sharing options...
trq Posted January 7, 2011 Share Posted January 7, 2011 In that simple example there is no need for all that code. The same thing could be achieved using.... define('APPLICATION_PATH', realpath('../')); set_include_path(get_include_path() . PATH_SEPARATOR . '../'); Now, the thing is, if you wanted to add more than one simple path you would use the code you posted. You know that implode takes an array and turns it into a string using a specified char as a separator. So.... $a = array('a', 'b', 'c'); echo implode('|', $a); Produces a|b|c Now, you know that an include path looks something like (on Linux) .;/usr/share/php;/usr/share/Zend/lib;/usr/share/www/lib So, if that is our current include path, and we take the code you posted above (and assume that realpath('../') produces /home/thorpe/var/www). Our include path would now be... .;/usr/share/php;/usr/share/Zend/lib;/usr/share/www/lib;/home/thorpe/var/www Quote Link to comment https://forums.phpfreaks.com/topic/223715-how-set_include_path-and-implode-and-path_separator-work-together/#findComment-1156444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.