Introduction to PHP

Hello everyone, welcome to the first tutorial to Hypertext Preprocessor (PHP)! This article is meant to build a strong PHP foundation for you by introducing you to what PHP is about and the basics of PHP. You will need to have a certain degree of understanding of Unix systems and operating systems’ file permissions.


Introduction

PHP is a programming language that is used by millions of users worldwide. Learning PHP is fairly easy but being good at PHP is extremely difficult. Therefore, you will need to pay extra attention to this introductory article. The PHP code is interpreted using the PHP interpreter which is powered by the Zend Engine. Communication between the web server and the interpreter is handled by a PHP handler which could be a Comman Gateway Interface (CGI) or the web server’s PHP module. Below is a visual interpretation of how PHP is being handled when a user visits a website:

php-interpreter
These are the things used in the above setup:

  • Web server
  • PHP handler
  • PHP interpreter

Programmers usually sign up for shared PHP hosting so they will not have to bother about the web server, etc, and let the hosting company handle it. This means that they will just need to upload the files to the web server using a FTP file upload, visit the web page and TA DAH, like magic, the code will be interpreted and displayed to the visitor.


PHP Handlers

Some of the common PHP handlers are DSO (mod_php), CGI, suPHP and FastCGI. The PHP handler that is used in most shared hosting environment is suPHP as it offers the most secured PHP environment by ensuring ownership at all times of execution. suPHP runs PHP as a CGI module instead of an Apache module but it runs PHP under its owner. Any scripts that are not owned by the particular user cannot be executed. So if a user named “john” tries to execute “ken” 0777 PHP file, it will not be possible. So why is that good? In the event of a user’s account being compromised, the PHP environment is secured, limiting the damage to a single user account and preventing damage to other user accounts.


The PHP Code

PHP starts with an opening <?php tag and ends with a closing ?> tag. The file extension of PHP is .php and requires no compilation from the programmer. PHP comes with many built in functions such as echo(), print_r() and many more. These functions need to be closed with a semi-colon “;”. We will go more in-depth for functions in the next tutorial but for now, we shall being our Hello World program.

Example

<?php
echo "Hello World";
?>

Conclusion

So there you have it, PHP. I hope this article has helped built a strong foundation for you. If you have any questions, feel free to leave a comment below and I will get back to you as soon as possible.

Next Tutorial: PHP Syntax

Tutorial Overview: Fast Track Learning

Author: Woo Huiren

Howdy, I'm a IT student who is currently serving my full time national service. I do lots of things related to IT but I have an exceptionally great love for the web and opensource, so expect me to blog a lot about it! :)

Leave a Reply