I'm trying to include a custom path to a certain file using php's set_include_path
. Here's the code:
file.php
<?php
$path = 'classes/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
$obj = new MyClass();
$obj->methodCall();
?>
Here's my root directory structure
www
|_webapp
|_classes
|_MyClass.php
|_nbproject
|_file.php
All I get when I execute the script is this error message: Fatal error: Class 'MyClass' not found in C:\wamp\www\webapp\file.php
. I have tried including the file using require
and it works but I have hit a wall with set_include_path
. Does anybody know what I can do about this?
Thanks
MyClass
is defined. set_include_path()
allows to omit the path in the require_once
statement, not to omit the statement itself.I have the impression that the tool you have in mind is class autoloader.