Please help me

I want to declare a variable at head of a document but that variable value is at the end of the document for example

<?php

$title=‘this title is located inside head tag’; //1st value
?>

<?php echo $title ?>
<?php $title='this title is located inside body tag'; //2nd value ?>

I want 2nd value at my please tell me how to do this

Hi there,

If I understand you, you want the value “the title is located inside the body tag” to be in your title tag. Unfortunately in this example it will not happen because PHP parses code line by line and doesn’t go back. Once you echo your first title value that is it. You are declaring your second title value after you echo it. You either need to put your second declaration before your echo statement at the top, or close your html and reopen it and echo all over again, at the bottom, after your second declaration.

Hope this helps.

I am giving you two choose one is this way:-

<?php $title='this title is located inside body tag'; //2nd value ?> <?php echo $title ?>

In this example you will get the second $title in your title bar and

<?php $title1='this title is located inside head tag'; //1st value $title2='this title is located inside body tag'; //2nd value ?> <?php echo $title1.$title2 ?>
In this example you will get both the header together.

if this is what you want else be specific what exactly that you want

Sponsor our Newsletter | Privacy Policy | Terms of Service