HTML inside PHP?

I have a HTML code with a javascript tag in it and i want to insert that code in my index.php file but when i do my website cant be accessed anymore. It says something like Syntax error on line 2, unexpected<

How can i insert a HTML code inside a PHP file?Not really a master in programming so your help would be appreciated.


Yes i can paste it but it doesnt work

You can either break out of php

// do php stuff
<h1>html stuff now</h1>
// carry on with php

or echo html strings

// php stuff
echo ‘<h1>html stuff</h1>’;
// more php

Can you paste your code?

What doesn’t work? We need to see your code, hash just gave an example…

It most likely means that you forgot to wrap the output XHTML in quotes or something. It’s complaining about an error in syntax, so unless you can show us your code, we can’t help you find the error.

The code is-

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>
<html xmlns=“” dir=“ltr”>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8” />
<link rel=“stylesheet” href=“http://mywebsite/css.css” type=“text/css” media=“screen” />
<script src=“” type=“text/javascript”></script>
<script src=“” type=“text/javascript”></script>
<a href=“”></a>
<div id=“button”></div>
<div id=“popupContact”>
<a id=“popupContactClose”>x</a>
<a href=“”><img src=“” alt=“Go to” width=“412” height=“396”/></a>
<div id=“backgroundPopup”></div>

Please note the post#3
There are all you need.

I tried to echo the html as the post 3 says and it worked, there is no more syntax error but my website gets a bit messed up after the code is added.

The code i posted looks something like this in action-


The only difference is that the pop up loads automatically instead of pressing the button to load. And when i inserted the code in the php file my website did not look the same as before…it was really messed up and i dont know why. Any ideas?

as the post 3 says, you don’t need any echo at all.
You can break out of php. And insert any html you wish. As if it were HTML file.
Can you insert HTML code into HTML file? Well where is no difference.