HI,
I try to run a file thru terminal but am getting the error like "include path is not correct"
for example, i have a "test.php" in following folder
/home/sekar/test/file.php
in file php i've included a file "head.php" which is in ,
/home/sekar/test/includes/head.php
Thes head.php includes a class file called cls.php which is in class folder,
/home/sekar/test/classes/cls.php
i tried like this in terminal,
php /home/sekar/test/file.php
for a clear a view just have a look @ contents of the those three files,
file.php
<?php
include_once "./test/includes/head.php";
?>
head.php
<?php
include_once "./test/classes/cls.php";
?>
cls.php
<?php
echo "this is from cls file";
?>
Can anyone help me to get around this issue? Thanks!
I think that include_once()
basically inserts code into your file without evaluating it, so the path is relative to that of the including file (file.php, not
head.php).
Also, I'd do a bit of research on relative paths, as you're referencing from the directory /home/sekar/test/
, not the file's path.
This might work:
file.php
<?php
include_once "./includes/head.php";
?>
head.php
<?php
include_once "../classes/cls.php";
?>
cls.php
<?php
echo "this is from cls file";
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With