I know this error is very common, I've tried to search google, I did the tricks to no avail. So my setup is, I have 3 directories:
CLASSES->constants
PAGES
INITCONTROLS
EDIT: I've got new error:
*Warning: require_once(initcontrols/config.php) [function.require-once]: failed to open stream: No such file or directory in*
below is my fragment of code:
require_once("initcontrols/config.php");
<div>
<?php
$file = "initcontrols/header_myworks.php";
include_once($file);
echo $plHeader;?>
</div>
What is still lacking in here? Thanks for all help in advance.
This question is related to
php
This should work if current file is located in same directory where initcontrols is:
<?php
$ds = DIRECTORY_SEPARATOR;
$base_dir = realpath(dirname(__FILE__) . $ds . '..') . $ds;
require_once("{$base_dir}initcontrols{$ds}config.php");
?>
<div>
<?php
$file = "{$base_dir}initcontrols{$ds}header_myworks.php";
include_once($file);
echo $plHeader;?>
</div>
Put in config.php this
$config['rewrite_short_tags'] = FALSE;
The include path is set against the server configuration (PHP.ini) but the include path you specify is relative to that path so in your case the include path is (actual path in windows):
C:\xampp\php\PEAR\initcontrols\header_myworks.php
providing the path you pasted in the subject is correct. Make sure your file is located there.
For more info you can get and set the include path programmatically.
It is because you use a relative path.
The easy way to fix this is by using the __DIR__
magic constant, like:
require_once(__DIR__."/initcontrols/config.php");
From the PHP doc:
The directory of the file. If used inside an include, the directory of the included file is returned
Source: Stackoverflow.com