Echo Above Syntax

Hi there, I don’t think this is possible but will give it a shot anyhow. I have a page which uses a PHP include to import the head section of the site.

I have my syntax and I want to echo a query above the syntax in the head section for page title. Any work arounds for this?

Perform the query first and assign it to a variable, such as $title.

Then in the head include, echo the value of the $title variable.


<title><?php echo $title; ?></title>

Hi pmw57, so I could echo $title above the syntax? I’m not too sure what you are meaning. Could you explain a little more, still learning :slight_smile:

master php file


// database stuff, and then
$title = $row['title'];

include 'head.php';

The included file is just dumped in with the rest of the code in the master, so the include could be:

head.php


?>
<head>
    <title><?php echo $title; ?></title>
</head>
<?php

Ok, got it. All working perfectly now. Thanks for your time and help :smiley: