PHP - Introduction
PHP (or PHP: Hypertext Preprocessor) is a server-side web scripting language designed solely for the purpose of back-end web development and it is rendered as HTML on front-end once it is viewed on a web browser. It is Open Source cross-platform scripting language meaning that it executes well on any given major platform.
Although it works very well without a database system but it is usually used alongside a database management system backed up any major DBMS application such as MySQL, Oracle, PostgreSQL, Informix, Sybase, or Microsoft SQL. One good thing about PHP language is that if you are good at C-Language then you will learn PHP without breaking a sweat as PHP syntaxes are C-Like.
Other than supporting Database system PHP is quite compliance mailing and directory protocols streams such as IMAP, POP3, and LDAP.
Topics to be covered
We will cover the following topics in this lesson
- Basics of PHP
- Outstanding Features of PHP
- Hello World
The journey of PHP began back in 1994 when its author "Rasmus Lerdorf" started writing CGI programs (C-Language) for the purpose of maintaining his personal homepage. While in its initial stages Rasmus started using his web program to work out with web forms and to communicate using databases and thus first even name of PHP was "Personal Home Page" as this language was built solely for maintaining Rasmus's home page.
Later on after further improvement and development in the language its official versions released and popularity was gained once PHP 3 was released. And next major version PHP 4 gained much more popularity especially because it added support for JAVA language. Each version that followed PHP 4 became more mature and more usable especially on Open Source platforms but also on Windows Servers.
Basics of PHP
The following are some of the basic tasks that can be done using PHP.
System Functions: PHP is able to create and write a new file and open read and close existing files on the system
PHP Forms: PHP can handle all sorts of forms such as gathering data from user input (from front end web page) or can fetch data from preexisting files on server. Data once fed in to the form can be sent via e-mail or saved to a file.
Variable: The name of memory location that is used to store data at runtime is known variable, it can be either local or Global (meaning that it can be reachable from any area of the script)
Constant: A variable whose value cannot be stored at runtime. It identifies a simple value, a constant must begin with letter or an underscore.
Operators: are used to perform various operations on variables and their values. Following are four types of operators:
- Arithmetic operators are used to assign numeric data
- Assignment operators are used to allocate data to variables
- Comparison operators are used to compare against values of two or more variables
- Logical operators are used to equate conditions
Decision: Making PHP makes decision within the code by using If Else and Switch Case which offer you to execute code section based on specified conditions. This increase the dynamic behavior of PHP.
Interaction: PHP interacts with server in an actual way. The process request is sent to the Server if extension is matched with PHP server then the request is fetched with the result otherwise forward the request concerned server.
Outstanding Features of PHP
The following are some of the out standing features of PHP
- Simplicity: PHP is uncomplicated to use and learn because there is no such thing as complexity when it comes to the coding of PHP script. Functionality of PHP is simple because a lot of functions are already predefined and the central feature of PHP is that it is compatible for any framework.
- Efficiency: PHP provides the feature of eliminating unnecessary memory allocation
Changeable upload file size as we want and also can change memory size of execution as necessity through the php.ini file
- Flexibility: It is easy to learn because most of the syntax are similar to the likes of C-Language and Pascal.
- Ease: PHP is embedded with different languages like JAVA, XML, and HTML etc. PHP is able to be run on different devices like cellphone, home PC, Servers or many other architecture easily. All it takes is an Operating System on the architecture that supports Linux/Unix or Windows kernel. It supports several database engines like MYSQL ,INFORMIX and ORACLE etc.
- Free to use: PHP is free of cost and there is no license that needs to be bought. And platforms in which PHP run are also either free of very inexpensive (such as Apache).
As with any other language PHP can also be tested by writing down a Hello World code. With PHP it is fairly easy and very short code and all it takes is echoing of the statement "Hello World!" Below is the example of how Hello World script can be written for PHP language
<?php echo "Hello World"; ?>
<?phpis the opening PHP tag and it is mandatory. This tell the compiler that the code is PHP therefore it should be interpreted.
echo "Hello World";echo is used to print either in web browser or terminal window.
?>is the closing PHP tag. In purely PHP files, the closing tag is usually left out but if you embed PHP code within HTML then you have to close it with the tag.
If you found this tutorial useful, support us by using the social media buttons to like and share the tutorial. If you didn’t find it useful, please use the comments section below to let us know how we can do better next time.
Subscribe to our newsletter, like our Facebook fan page or follow us on Twitter to get free updates when we publish new tutorials