Page 1 of 1

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

Posted: Sun Apr 13, 2014 5:48 am
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

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

Posted: Sun Apr 13, 2014 8:34 am
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?

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

Posted: Sun Apr 13, 2014 1:37 pm
by Weirdan
.html files are usually not processed by PHP engine. You could try to rename it to .php to start with.

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

Posted: Wed Apr 16, 2014 3:09 pm
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.

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

Posted: Wed Apr 16, 2014 3:16 pm
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 !!