I want to include path to my "var\www\html\leave\functions" folder so that i can access my functions without specifying whole path say include('leave\functions\xyz.php');

instead by giving include('xyz.php');

This is my code which i used in my php file to add this folder path to the include statement.

$path=ini_get('include_path');

$sep=PATH_SEPARATOR;

$docroot=$_SERVER['DOCUMENT_ROOT'];

$dirname=dirname($_SEVER['PHP_SELF']);

ini_set('include_path',$path.$docroot,$dirname,'/leave'.'/functions');

    I think the function your looking for is [man]set_include_path/man Ex:

    $path = $_SERVER['DOCUMENT_ROOT'] . '/leave/functions';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    

      Thanks for your reply

      but i used the command u sepcified but it give

      Fatal error: Call to undefined function: set_include_path() in /var/www/html/zubin/leave/header.php on line 4

        You must be using PHP older than version 4.3. In that case you will have to use [man]ini_set/man

        $path = $_SERVER['DOCUMENT_ROOT'] . '/leave/functions';
        ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $path);
        

        The other question would be if you want that folder to be looked in first. If so just switch $path and get_ini() If that doesn't work you must have something locked down so include_path cannot be changed.

          I think its not recognizing what PATH_SEPARATOR is it gives me this message

          Warning: Failed opening 'leave_dbconnect.php' for inclusion (include_path='.:/usr/share/pearPATH_SEPARATOR/var/www/htmlzubin/leave/functions') in /var/www/html/zubin/leave/leave_authenticate.php on line 3

            Hi,

            seems to be a constant, something like

            define('PATH_SEPARATOR',':');

            You need to use : on UNIX systems and ; on e.g. Windows systems.

            Thomas

              its a constant but its system defined constant so i dont have to define it manually.

                its a constant but its system defined constant so i dont have to define it manually.

                  Yes, it is a standard predefined constant. However, it might not be defined for some reason.. Check to make sure it is:

                  print(defined('PATH_SEPARATOR') ? 'Yes' : 'No');

                  And if it isn't set for some odd reason, set it on your own:

                  if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                     define('PATH_SEPARATOR', ';');
                  } else {
                     define('PATH_SEPARATOR', ':');
                  }

                    Its still not working i have given the code like this

                    define('PATH_SEPARATOR', ':');

                    $path = $_SERVER['DOCUMENT_ROOT'] . '/zubin/leave/functions';
                    ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . $path);

                    but its still showing me the default path and not the new path it gives me error message like this

                    Warning: Failed opening 'myadmin_query.php' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/zubin/leave/leave_entry.php on line 2

                    Warning: Failed opening 'leave_dbconnect.php' for inclusion (include_path='.:/usr/share/pear') in /var/www/html/zubin/leave/leave_entry.php on line 3

                      Are you setting the includes path before including the files? Also, are you on a hosted website or do you have your own server?

                        I have already created the files but now i want to seperate all my functions in seperate folder so i want to include the folder in my include path so i dont have to give whole path to my folder in my files.
                        Another this i am creating this for intranet within my company and not on internet.

                          Which PHP version do you have ? Please post the script as attachment.

                          Thomas

                            if i echo the ini_get

                            echo ini_get('include_path');

                            it shows me the path with my folder

                            .:/usr/share/pear:/var/www/html/zubin/leave/functions

                            but still i am not able to access the file which are stored in functions.

                              Please post leave_entry.php

                              Thomas

                                I am posting leave_entry, it is just calling to two files (or functions) which are stored in functions directory.

                                  Hmmm,

                                  I can't see the lines that set the include_path in that file ? Which file contains that lines ? You need to add that lines to every script that needs the customized include_path.

                                  Another way (if .htaccess files are working) is to put a .htaccess file in DOCUMENT_ROOT that sets the include_path.

                                  Thomas

                                    i dont know about .htaccess file, for that i think i have to ask admin for it.

                                    i want is to put all the include path in one single file so that i can call this single file from any program without giving names of all functions.

                                      Write a Reply...