Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts

    Set an inclue path?

    Hi All,

    I have a file called header.php which I call into various pages on my site. In it I want to link to a file called process.php

    Now this file lives in a folder in the top level called connections

    PHP Code:
    <?php
     ini_set
    ('include_path''/connections');
     include(
    'process.php'); 
     
    ?>
    So the plan is if I’m calling header.php in a page from anywhere on a page that could be within a folder and then within another folder it will still work. However it does not?

    Any ideas?

    Thanks

  • #2
    New Coder
    Join Date
    Nov 2007
    Posts
    12
    Thanks
    0
    Thanked 1 Time in 1 Post
    There are 2 special functions for this.
    Vaiants of ini_set() / ini_get()

    http://php.net/get_include_path
    http://php.net/set_include_path
    Can be combined to (temporary just for script) add paths to the include setting.
    PHP Code:
    <?php

    // separator
    $sep ';'// For Windows
    //$sep = ':'; //for Unix, Linux

    // new path(s) without ending slash
    $addpath1 'C:/Apache/htdocs/connections';
    $addpath2 'C:/Apache/htdocs/templates';
    set_include_pathget_include_path() . $sep $addpath1 $sep $addpath2 );

    include(
    'process.php'); // in the '/connections' directory

    ?>
    echo "PHP 5.2.5";
    exit ( "Script End" );


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •