Jump to content

Cannot retrieve variable from required file


nscherneck
 Share

Recommended Posts

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?

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...