Related Posts


What is PHP?

PHP is a server-side script which can connect to a database. Most commonly a MySQL database but there are many others including Informix, Sybase, Oracle, PostgreSQL and more. Essentially it can be used to process existing information submitted on a webpage. This often includes forms that a user fills out and submits to the server. But it can also be used to post information to a webpage directly linked to the information the user submits.

PHP is often considered one of the easiest web-programming languages. The PHP script is inserted usually between the <html></html> statements on a webpage.
  • <html>
  • <body>
  • <?php
  • echo "Hello there";
  • ?>
  • </body>
  • </html>
The PHP start-tag is "<?php" and end-tag is "?>" without quotation marks. These are also referred to as opening and closing statements.

PHP Echo

Echo is one of the most basic PHP commands.

  • echo "Hello there";

The "echo" command tells the script to output information. This is the same as posting information to the webpage. The echo command here outputs the text "Hello there". The echo text needs to be contained within quotation marks and include a semi-colon at the end of each line. The original piece of code from the What is PHP? section would look like this.

  • Hello there
There can be multiple echo statements in a single script.

PHP Comments

To keep your code well structured and organized you can use comments to aid navigation and understanding. Comments are essential when you're working or sharing your code with multiple people. As it might prove difficult for them to understand exactly what each section of code does unless you explain it to them. This makes it easier to understand and improves efficiency for programmers.
  • <html>
  • <body>
  • <?php
  • /* This is the echo that welcomes visitors */
  • echo "Hello there";
  • ?>
  • </body>
  • </html>

The orange highlight marks the comment. You can use as many comments as you like in your codes. It allows you to come back later or the next day and know exactly where you are and what you're looking at, saving valuable time. 

To be continued.