Jump to content
Larry Ullman's Book Forums

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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...