-2

I have started learning PHP and trying a simple echo statement on XAMP on my machine. This is my code :

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<title>Hello</title>
<link rel=”stylesheet” type=”text/css” href=”common.css” />
</head>
<body>
<h1> <?php echo “Hello, world !”; ?> </h1>
</body>
</html>

When I run this I am getting this error :

Parse error: syntax error, unexpected '!', expecting ',' or ';' in C:\xampp\htdocs\PHP\hello.php on line 9

I have no clue as to what is going wrong.

halfer
  • 19,824
  • 17
  • 99
  • 186
Knownow
  • 353
  • 1
  • 4
  • 17

2 Answers2

1

Try

<?php echo "hello, World!"; ?>
Abhishek
  • 1,008
  • 1
  • 16
  • 39
1

If you are using MS Word to write your code, don't. Use Notepad++ or Sublime Text - even plain ol' Notepad is better.

Also, you must run your program using localhost/PHP/hello.php - not c:\xampp\htdocs\PHP\hello.php

In the browser address bar, type localhost/PHP/hello.php

cssyphus
  • 37,875
  • 18
  • 96
  • 111
  • I am using notepad++ and running it using localhost/PHP/hello.php – Knownow Dec 16 '16 at 11:58
  • Do you understand why we have identified the incorrect quotes as the reason for your problems? The quotes posted in your question are "smart quotes" inserted by word processors like MS Word. ASCI double quotes are not slanted: ` " ` How did you get the smart quotes in your question? – cssyphus Dec 16 '16 at 12:05
  • Yes , I got it now . Never knew there were different type of quotes . Thanks a lot . – Knownow Dec 16 '16 at 13:02