tgavin Posted November 21, 2012 Share Posted November 21, 2012 I'm encountering a weird one on IIS with PHP 5.4.7 in my script I'm trying to include my config.php file (located in the same directory), so I put require_once('config.php'); as I normally would on Linux. Well, later in my script I'm getting an undefined variable notice, even though the var has been defined in config.php. So I open config.php and do this $base_dir = 'www'; var_dump($base_dir); exit; now, not only do I now see a result from the var_dump, the script doesn't die as it should, and I continue receiving the undefined variable notice at the same point in the script. WTH? Even if I do require_once('config.php); var_dump($base_dir); exit; I get no results - just the undefined var error. it's almost like the config.php file isn't being included. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/270995-require_once-not-working/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 21, 2012 Share Posted November 21, 2012 Show us the opening php tag you are using in the config.php file. Quote Link to comment https://forums.phpfreaks.com/topic/270995-require_once-not-working/#findComment-1394151 Share on other sites More sharing options...
Muddy_Funster Posted November 21, 2012 Share Posted November 21, 2012 var_dump() doesn't kill a script. die(var_dump($base_dir)); will kill the script. you are requiring the file before you call the variable...right? Quote Link to comment https://forums.phpfreaks.com/topic/270995-require_once-not-working/#findComment-1394155 Share on other sites More sharing options...
tgavin Posted November 21, 2012 Author Share Posted November 21, 2012 (edited) PFMaBiSmAd: Excellent catch! I'm implementing a system that a previous developer had created and he's using bullcrap shortcuts all over the place. Very lazy and insecure. That fixed it, thank you! Edited November 21, 2012 by tgavin Quote Link to comment https://forums.phpfreaks.com/topic/270995-require_once-not-working/#findComment-1394157 Share on other sites More sharing options...
PFMaBiSmAd Posted November 21, 2012 Share Posted November 21, 2012 @Muddy, he's got an exit; statement in the code. Quote Link to comment https://forums.phpfreaks.com/topic/270995-require_once-not-working/#findComment-1394164 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.