PHP embeded in HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
El Vasco
Forum Newbie
Posts: 15
Joined: Tue Jan 04, 2011 12:05 pm

PHP embeded in HTML

Post by El Vasco »

Hi All,
I am struggling to get the embeded PHP running in my development enviroment without success...
I write the code below and the only message I get in the browser is:

TEST FROM HTML

When I do "View Source" I get:

Code: Select all

<html>
<head>
<title> Prueba </title>
</head>
<body>
<h1> TEST FROM HTML </h1>
<?php echo '<h1>TEST FROM PHP</h1>';?>
</body>
</html>
What I guess means PHP is just not running... Any suggestions or clues about what I am doing wrong... ?

Thanks !
El Vasco
Last edited by Benjamin on Fri Jan 07, 2011 4:49 pm, edited 1 time in total.
Reason: Added [syntax=php] tags.
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: PHP embeded in HTML

Post by Neilos »

If that is what you see when you view source then the php is not being parsed. Most likely you have put php in a .html file. If this is the case you will need to change the .html to .php. If you cannot do this as you already have incoming links then you can try things like http://php.about.com/od/advancedphp/p/html_php.htm
El Vasco
Forum Newbie
Posts: 15
Joined: Tue Jan 04, 2011 12:05 pm

Re: PHP embeded in HTML

Post by El Vasco »

Thank You, Neilos ! You are completly right. I was trying to run PHP from a .html file :( ... I will read the information in the link you sent me.
Thanks !
El Vasco
Neilos
Forum Contributor
Posts: 179
Joined: Fri Nov 19, 2010 2:07 am

Re: PHP embeded in HTML

Post by Neilos »

It's an easy mistake, God knows we all make them! lol. Beware though the link I gave was just the first I found, I didn't even read it so I don't know if it is a good option but at least you now know what to look for :)

Glad to have helped.
Post Reply