Simple Php Script

Hello World Php Script

  • Php is a server side scripting language.
  • Php stands for Php Hypertext Preprocessor
  • Since php is an interpreted language, it does not have to be compiled in order to run
  • This means that you can simply type the code that you want to execute, and it will run immediately, assuming you have used the proper syntax
  • Please note, that php must be installed on your server for any php code to execute. Most hosts have php pre-installed

Here is an example of a simple php script:

<?php echo “Hello World! This is my first php script.”; ?>

While the above sample is very basic, it is actually a php script.

The result on the end user’s screen would be:

Hello World! This is my first php script.

To embed this php script in an html page, all you would need to do is type this into a plain text file using notepad or any plain text editor, and save as script.php

<html>

<title>My first php script.</title>

<body> <?php echo “Hello World! This is my first php script.”; ?> </body>

</html>

No matter how complex your php scripts become in the future, the same basic structure will work as far as the coding is concerned.