PHP Introduction
PHP is a server-side programming language that is mostly used to build websites and web applications. The name stands for PHP: Hypertext Preprocessor (at the start it meant Personal Home Page). PHP code runs on the web server, and the visitor receives only the result, which is normal HTML.
In this PHP tutorial you will learn PHP step by step, from the basics to forms, files, sessions, object oriented programming and MySQL.
What can PHP do?
- Create static and dynamic web pages, like a blog or an online shop.
- Collect and process form data, for example a login or a contact form.
- Read data from a database and save data in a database like MySQL.
- Create, read, write and delete files on the server.
- Send emails, work with cookies and sessions, and build APIs.
- Run from the command line to do automatic jobs.
How PHP works
- The visitor opens a PHP page in the browser, so the browser sends a request to the web server.
- The web server runs the PHP code of that page.
- PHP may read a database or files and prepares the HTML.
- The server sends the HTML to the browser. The visitor can not see your PHP code.
Your first PHP program
PHP code is written between <?php and ?> tags, and it is saved in a file with the .php extension. To run it you need a server, see PHP Installation.
<?php
echo "Hello, World!";
?>
Output:
Tutorials Class - Output Window
Hello, World!
Features of PHP
- Easy to learn: the syntax is simple and close to C and JavaScript.
- Free and open source: you can download it from php.net and use it without any cost.
- Cross platform: it runs on Windows, Linux and macOS, and works with Apache, Nginx and other web servers.
- Database support: it works with MySQL, PostgreSQL, SQLite and many more.
- Huge community: a lot of help, tools and frameworks like Laravel are available.
- Powers popular software: WordPress, Drupal, Joomla and Magento are written in PHP.
A short history
- 1994: Rasmus Lerdorf created PHP to manage his personal website. The first public release was in 1995.
- PHP 5 (2004): brought a proper object oriented model.
- PHP 7 (2015): made PHP much faster.
- PHP 8 (2020): added many new features like named arguments, the match expression and the JIT compiler. PHP 8 is the version to learn today.
Note:
Always use a PHP version that still gets security updates. You can see the list of supported versions on php.net.
What next?
Learn some common words in PHP Terminology, then set up your computer with PHP Installation.
Congratulations! Chapter Finished. Learn more about the similar topics:
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| What is PHP? |
| Who is the father of PHP? |
| What is Open Source Software? |
| What is the latest version of PHP? |