Nihir
Nihir

Reputation: 135

Cannot get include path working

I am trying to include a php directory that is currently in a subdirectory by either editing the php.ini configuration file or with the following method:

string set_include_path ( string $new_include_path )

I am currently trying to use the above method and have placed it in a login.php (same subdirectory as the php directory that is to be included) file so I can set the path. Here is what I have:

set_include_path(get_include_path() . PATH_SEPARATOR . '/dt2/php');

The current path is echoed out with echo get_include_path(); and the following is printed to the page:

.:/usr/local/lib/php-5.3.13/lib/php:/dt2/php

I understand that the different paths are separated by colons.

In the directory dt2/php there is a library.php file that contains the following function:

function testFunction() {

    echo "hello";

}

The function is then called in login.php.

However, I get the following error:

Fatal error: Call to undefined function testFunction() in /hermes/bosnaweb06a/b2320/(domain name here)/dt2/login.php on line 25

I would appreciate any help and thank you for your time in advance.

Upvotes: 0

Views: 164

Answers (1)

Siim Kallari
Siim Kallari

Reputation: 861

Since it is in your dt2 where your homepage is (probably), you need to include full path to dt2: /hermes/bosnaweb06a/b2320/(domain name here)/dt2/php

At the moment it is looking path from your server root: /dt2/php/

Upvotes: 1

Related Questions