I'm new to PHP, and i start to use XAMPP to build the site. I have code below
db.php:
<?php
$hostName='localhost';
$userName='xxxxxxxxx';
$userPass='xxxxxxxxx';
?>
and a test.php:
<?php
include 'db.php';
echo $hostName;
?>
but now it show me Notice: Undefined variable: hostName
what i found is the register_globals need to set "on" in php.ini, but after i set, the XAMPP show: Directive 'register_globals' is no longer available in PHP when i restart XAMPP.
i move the same code to Hosting24 but it's work, anyone can help?
I just got bit by a similar problem - definitely not OP's problem but falls under the question's title.
In my case I had PHP short tags disabled on the server, but the included file accidentally used short tags. When the file was included, functions were undefined and there were no inclusion errors. What I think happens in this situation is that the file is included but treated as an empty file.
If you have an "undefined" problem after inclusion/requirement, check your file tags - just in case.
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