Question

I have a problem with config.php that need your help. I have 3 files named index1.php, caller.php and config.php. The index1.php is located in root directory and the others are located in subdir which is the sub-directory of root.

index1.php

<?php
require_once("subdir/caller.php");
?>

caller.php

<?php
require_once("config.php");
?>

config.php

<?php
echo "Hi from config.php";
?>

When I try http: //localhost/index1.php the browser shows nothing (FireFox & IE). If I change the code in caller.php to require_once("subdir/config.php") then I can see the text. In the other hand, if I change the name of config.php to something else like convit.php and update the code in caller.php to require_once("convit.php") then I also can see the text.

Can you explain to me why. I have just installed XAMPP on Windows 8 and have not configured anything in the system except fixing the security vulnerabilities.

Kind regards, Thang

Was it helpful?

Solution 2

It may be a bug of XAMPP (xampp-win32-1.8.3-3-VC11-installer). I have tried with WAMPSERVER (Wampserver2.4-x64) and have no problem.

OTHER TIPS

you'd better use

<?php require_once(dirname(__FILE__)."config.php"); ?>

in caller.php

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top