0% found this document useful (0 votes)
301 views

The PHP Programming Language

Uploaded by

masterxd.mlg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
301 views

The PHP Programming Language

Uploaded by

masterxd.mlg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

University of Ghardaia

Department of Mathematics and Computer Science


First-year Bachelor's degree, Group (3)

PHP, What is It and What Does it Do?

What is PHP?:
PHP, short for Hypertext Preprocessor, is a versatile scripting language primarily designed for
web development purposes. Unlike client-side programming languages such as JavaScript,
PHP is specifically intended to be used on the server side or the back end of websites. Its
primary function is to execute scripts and interact with databases like MySQL or MongoDB.
PHP is a powerful tool for developers, allowing them to create dynamic and interactive web
pages.

History of PHP:
in 1993, Danish-Canadian programmer Rasmus Lerdoff began developing PHP with the
purpose of maintaining his personal web page, it started as a set of Common Gateway Interface
(CGI) binaries written in C, primarily for tracking visits to his online resume. Over time, it
morphed into a more robust scripting language with the release of PHP/FI (Forms Interpreter),
which he used to work with forms and communicate with databases, he would later go on to
create PHP 4 and 5 in the following 3 years, then PHP 6 and 7 in the years 2004 and 2015
respectively, and finally in November of 2020 PHP 8 was released, as of today it is used on 82%
of the web including Facebook and Wikipedia despite having a notorious reputation for being
the most hated language by developers.

How Does PHP Work?:


PHP code; which will be embedded into an HTML source document that is requested by the
client’s browser, will be processed by an interpreter in the back-end of a website with PHP
installed, the former usually being a file system mounted on a Linux distribution such as Apache
or Solaris, Where it is processed and then executed within this server environment, enabling it
to run scripts or make any necessary requests or updates with the database, subsequently, the
processed information is then sent back to the client’s browser.

Why Use PHP?:


PHP has evolved to be one of the most used languages on the web, and that is because of its
numerous advantages, here are a few benefits of using PHP on your website.

1. Ease of Learning and Use: PHP has a syntax that is easy to understand, especially for
those with a background in C-style languages. Its simplicity makes it accessible to
beginners and allows for rapid development
2. Platform Independence: PHP is platform-independent, meaning it can run on various
operating systems such as Windows, macOS, or Linux, This ensures the portability of
PHP-based applications.
3. Cost-Effectiveness: As an open-source language, PHP is free to use and distribute,
making it an attractive choice for businesses and developers looking to minimize costs
without sacrificing functionality or performance.
4. Blazingly Fast Performance: PHP's performance has been significantly improved
through optimizations, resulting in efficient speed and responsiveness. Its lightweight
nature and horizontal scalability make it popular for high-traffic applications.

How to Use PHP:


To be able to use PHP, create a .PHP file and
open it in any code editor, the document should
contain typical HTML source code, however, your
PHP code must be prepended by the symbols
“<?php” and appended by “?>”, and then
embedded into the HTML document as shown in
the image that follows.

Some Basic PHP Syntax:


1. Outputting strings: To output a string, use the function “echo” followed by the string you
want to output.
E.g. echo " hello world "
2. Variables: To use variables, type the variable name prefixed by the “$” sign, then use
the equal sign “=” to initialize a value into it. note that you don’t have to declare its type.
E.g. $name = "Islam lameche"
3. If-else statements: To use an if statement, start by typing the “if” keyword followed by
parentheses containing the condition you want to check, and then curly braces
containing the actions you want to execute if the condition returns true.
E.g. if ( $balance = 0 ){ echo " you're a broke piece of shi "}
4. Arrays: There are many ways of declaring arrays in PHP, one method is to use the
array() function, where you would insert elements inside the parentheses separated by
commas.
E.g. $fruits = array( “apple”, “orange”
5. Loops: There are various types of loops in the PHP language, the most useful one is the
for-each loop, to declare it, type the “foreach” keyword followed by parentheses, and
inside the parentheses add the name of the array you want to traverse and then the “as”
keyword and the iterator variable, then curly braces containing the actions you want to
execute each iteration.
E.g. foreach ( $dictionary as word ) { echo $dictionary . ' '}

Conclusion:
PHP is one of the most useful web development tools and even tho it is infamous among
coders, it is still dominating the field in both coverage and performance.

You might also like