Jump to content
Larry Ullman's Book Forums

Chapter 9-9.11 Confusion On Set_Include_Path


Recommended Posts

$path = '/usr/local/pear/share/pear/';

set_include_path(get_include_path() . PATH_SEPARATOR . $path);

What does this line do?

 

PHP documentation explains it as extending the include path.

 

In this example we add /usr/lib/pear to the end of the existing include_path.

 

<?php

$path = '/usr/lib/pear';

set_include_path(get_include_path() . PATH_SEPARATOR . $path);

?>

echo outputs :

.:/opt/lampp/bin/php:/usr/local/pear/share/pear/

 

Can someone please break down the concept for me?

 

Also login seems to work when even if I do this:

(path where QuickForm2 is installed for my setup:

Ubuntu 16.10 xampp-5.6.30-0)

$path = '/opt/lampp/lib/php/HTML/';
Link to comment
Share on other sites

Am not sure if my understanding of the concept is correct, so I'd appreciate any input to help me with it.

set_include_path(get_include_path() . PATH_SEPARATOR . $path);

This line tells PHP to first search for the included file (in this Script "require('HTML/QuickForm2.php');") in the path returned by "get_included_path()". If the file is not found there, then PHP will look for the file in "$path".

 

Have I got it right?

Link to comment
Share on other sites

Yes, that's exactly right. And the "path" is the list of directories in which the operating system will look for stuff. The path normally refers to executables, and this is a variant on that: the include path.

Link to comment
Share on other sites

 Share

×
×
  • Create New...