Invalid tag start: "<?". Question marks should not start tag

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
kouroshby
Forum Newbie
Posts: 3
Joined: Sun Apr 13, 2014 5:39 am

Invalid tag start: "<?". Question marks should not start tag

Post by kouroshby »

Hi All
I am new to php programming and my first attempt gave me the error above (using F12 ie developer tool).
The code in my file myfirstphp.html is:

Code: Select all

!DOCTYPE html> 
 
<html>
<head>
	<title>Hello world script</title>
</head>
<body>
<?php echo "<p>Hello world!</p>"?>
	<p>This is HTML only</p>
	 
	<?php	
		echo "<p>Hello world again!</p>";
	?>
	<p>This is the second HTML section.</p> 
</body>
</html>
and the output in IE11 is:
[text]Hello world!
"?>
This is HTML only
Hello world again!
"; ?>
This is the second HTML section.
[/text]--------------------------------------------
which is not what I expected. I assume IE11 is not recognizing the <? start tag.
can anyone help?
thanks
kourosh :D
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Invalid tag start: "<?". Question marks should not start

Post by requinix »

IE should never see those to begin with. If it is then your PHP code isn't being executed.

Are you sure you have PHP installed? What is the exact URL you're testing this page on?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Invalid tag start: "<?". Question marks should not start

Post by Weirdan »

.html files are usually not processed by PHP engine. You could try to rename it to .php to start with.
kouroshby
Forum Newbie
Posts: 3
Joined: Sun Apr 13, 2014 5:39 am

Re: Invalid tag start: "<?". Question marks should not start

Post by kouroshby »

hey requinix and weirdan
I have apache server installed and myphp is ok when I run the apache admin. I took the code from a book on php and the author says we can have php code in an html file. it is very strange.
kouroshby
Forum Newbie
Posts: 3
Joined: Sun Apr 13, 2014 5:39 am

Re: Invalid tag start: "<?". Question marks should not start

Post by kouroshby »

hey again. I just changed the extension to .php and it worked. now I need to find out why all the code in my book is written in .html !!
Post Reply