i am new to PHP, i typed in a hello world php program and opened it using the web browser, but the end tag "?>" is also getting displayed, could any one correct my code ...

<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
echo <b>Hello World! </b>
?>
</body>
</html>

Hello World! ?> <<-- this is the output that i get...

i am new to PHP, i typed in a hello world php program and opened it using the web browser, but the end tag "?>" is also getting displayed, could any one correct my code ...

<html>
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
echo '<b>Hello World! </b>';
?>
</body>
</html>

text has to be enclosed
php statements end in ;

You need to save the module as xxx.php If you saved it as a .htm it probably won't deal with the PHP section correctly when you run it.

Chris

i saved it as hello.php, in "C:\Program Files\Apache Group\Apache2\cgi-bin" ... then when i double click on that .. i dont get the expected output

What does it say in the address bar? If it says "C:\Program Files\Apache Group\Apache2\cgi-bin\filename.php" then you aren't running it through your server. It is not being parsed as PHP. You have to view it through your server: "http://localhost/filename.php" or "http://127.0.0.1/filename.php" (the same thing).

Just to add to that is it hasn't been made clear, there are two ways the view a file on localhost and one won't load the php code. There is the method of http://localhost/path/to/file/filename.php which in most cases will work then there is the other method of viewing it on the file protocole which can be file://C:\path\to\file\filename.php or C:\path\to\file\filename.php
You need to make sure that you use the method which has the http:// before the path and no C:\ in the path. This way the data request is sent through apachie and php which can then do the server side processing instead of passing that stage. So in short, you need to make sure you use http://localhost/path/to/file/filename.php

This article has been dead for over six months. Start a new discussion instead.