Can I insert a PHP Variable into the HTML element <span>

Hi Folks,

This is frying my brain.

<?php $Message="This is the message I hope will appear when I hover"; ?>

hover me

The above two lines of code doesn’t not give me the text I want when I hover over the ‘hover me’ text.

It gives me: <?php echo $Message; ?> instead.

Any ideas?

Many thanks in advance :slight_smile:

Is the file a .php extension?
Are you running this out of a web server (either Apache or IIS)?

Yes the file has a .php extension and I am using Apache Server.

And you are running it from the htdocs directory? The only way I can replicate what you are saying is to run it as an html page.

[php]<?php $message = 'test string of the string of the test of the string.'; ?>

Hover [/php]

Oops!!! It has been a while since I felt like quite such an idiot - I thought the file extension was using was a .php but it was (of course) a .html. Well spotted and many thanks.

Sponsor our Newsletter | Privacy Policy | Terms of Service