Welcome to Our Free Tutorial!

Example of Simple PHP Code

Previous Home Next

Below the example of one of the simple First PHP and HTML page. Write the code into html editor or dream viewer and save the file firstprog.php extension.

  1. Create a new file in your dream viewer editor.
  2. Write some PHP code.
  3. Save the file with a .php extension.

The .php extension tells the web server that process this as PHP file. If you not save the file .php extension, you save the file .html extension the server will not process your PHP code and the server just give output it to screen.

HTML and PHP Code

<html>
<head>
<title>PHP Syntax Example</title>
</head>
<body>
<h2>Welcome to the aonestudy PHP </h2>
<?php
  echo "Hello Simple PHP!";
print” Hello Simple PHP!”
?>
</body>
</html>

Output:

html and php prog

Note:- There are two type of output the text with PHP. We use the PHP echo and print command to write “Hello Simple PHP” display this on your browser, To display the message.

Previous Home Next