DEV Community

Cover image for A Quick Introduction to PHP
Patrice Williams
Patrice Williams

Posted on • Updated on

A Quick Introduction to PHP

What is PHP?

PHP is an open source scripting language used on the backend of software development. PHP is an acronym for “PHP: Hypertext Preprocessor”. In 1994, the first version of PHP was created by Rasmus Lerdorf. PHP files can hold text, HTML, JavaScript, CSS and PHP code. PHP files have the extension “.php”. PHP can be used to create, open, read, write, delete, and close files on the server. Form data can be collected with PHP and cookies can be sent/received. PHP is used to add to, delete or modify your database. PHP is integrated with many popular databases like MYSQL, POSTgreSQL, Sybase, Informix, and Oracle. PHP is also used to control user access and encrypt data. 8.0.2 is the newest version of PHP released February 2021. It contains many new features and optimizations like named arguments, union types, nullsafe operator and constructor property promotion to name a few.
 

Basic Syntax

The PHP script is first implemented on the server, and then the HTML result is sent back to the browser. The PHP script can be located anywhere in the document. The PHP script begins with <?php and ends with ?>. A PHP file generally contains HTML tags and PHP scripting code. In the following code, the function “echo” is a built- in PHP function that is used to output “Welcome to my World!”

<!DOCTYPE html>
<html>
<body>

<?php
ECHO "Welcome to my World!<br>";
echo "Welcome to my World!<br>";
EcHo "Welcome to my World!<br>";
?>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode

PHP is not case sensitive. So when using keywords (ex. If, else, while, echo, etc.), functions, classes, and user-defined functions they are not case-sensitive. In the code below, the three different echo statements are all equal and legal in PHP.
Code written in PHP must be included inside one of the following markup tags that are recognized by the PHP Parser.

<?php PHP code goes here ?>

<?   PHP code goes here ?>

<script language = "php"> PHP code goes here </script>
Enter fullscreen mode Exit fullscreen mode

Why use PHP?

Alt Text

PHP can be run across many different platform applications like Windows, Linux, Unix, Mac OS X and a number of other operating systems. PHP is compatible with almost all servers. It is open-source and free for all to use at https://php.net. This allows for a large and active international community that uses PHP. PHP was partially developed as an object-oriented language, so the code is reusable as possible. PHP was created to program web applications through built-in GET and POST functions, in addition to URL and HTML script functionality. PHP’s server side offers great versatility. PHP supports backend servers including Netscape, Apache, Microsoft IIS, iPlanet, Caudium, Xitami, and Tornado. PHP is also supported by 20 databases. PHP’s fast performance enables quick turnaround times with the database. Since PHP was initially developed for creating dynamic websites, PHP’s scripts are easily embedded into HTML files. This makes it easier for developers to convert static website code into dynamic websites. Websites that use PHP are Facebook, Wikipedia, Tumblr, Slack, MailChimp and Etsy.  

Works Cited

W3Schools. (n.d.). Php introduction. Retrieved March 15, 2021, from https://www.w3schools.com/php/php_intro.asp
PHP - Introduction. (n.d.). Retrieved March 15, 2021, from https://www.tutorialspoint.com/php/php_introduction.htm
7 global websites that use PHP in 2021. (n.d.). Retrieved March 15, 2021, from https://trio.dev/blog/companies-using-php

Latest comments (0)