Cannot retrieve variable from required file in PHP Posted July 15, 2016 PHP beginner here. I have the following in index.php (the two files live in the same directory)... <?php require_once( dirname( __FILE__ ) . '/functions.php' ); ?> <!DOCTYPE html> <html lang="en"> <head> <title><?php echo $nds; ?></title> </head> <body> </body> </html> ...and here is the required PHP file (functions.php)... <? php // test variable $nds = 'Test title.'; ?> This gives me an "undefined variable" error when tested in a browser. Is this an issue of scope?
Cannot retrieve variable from required file
in PHP
Posted
PHP beginner here. I have the following in index.php (the two files live in the same directory)...
...and here is the required PHP file (functions.php)...
This gives me an "undefined variable" error when tested in a browser. Is this an issue of scope?