Jump to content

Php - $title


Norman
 Share

Recommended Posts

Hello, I have an index.php and an header.php. I want to show a different title per page, then I have thought to include my header.php and there put this:

<title><?php $title ?></title>

.. and in my index.php put this:

<?phpinclude 'header.php';$title = 'My Index Title'; ?>

.. and so on for the other pages. But I get a 'undefinied variable' message. Why?

Link to comment
Share on other sites

Define your variables before you include a file that uses them. In your case:

<?php$title = 'My Index Title';include 'header.php'; ?>

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...