Note: The variable is set in included file, the issue is not an undefined variable, hence the duplicate question is not relevant to my question. PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"
Edit: i just noted my localhost include path is set to C:\xampp\php\PEAR when i did echo get_include_path(); but i don't get error for included file not found rather the variable is undefined.
I have 2 files in C:/xampp/htdocs/test/ index.php config.php
Content of index.php:
require 'config.php';
echo $name;
Content of config.php:
$name = 'xyz';
And i get Notice: Undefined variable: name
Where the $name = 'xyz' is in config.php which is included before using the variable.
I have to yet test it on live server. Please guide.
error_reporting(E_ALL ^ E_NOTICE);require 'config.php';instead ofinclude 'config.php';. This will throw a fatal error if file is not found.C:\xampp\php\PEARwhen i didecho get_include_path();