Jump to content

Cannot retrieve variable from required file

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">
    <title><?php echo $nds; ?></title>


...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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...