Welcome, Everyone! In today’s article, we’ll talk about one of the most important programming languages of the Internet, PHP. We’ll discuss what PHP is and how PHP works. This is going to be a series of articles covering the basics of PHP to help PHP learners understand the language. So let’s get started!
Web development is on rise and today from a very small business to the large organizations, everybody requires a web app or website to connect to more potential customers. So the web development is a good career to go in.
There are many technologies available to program websites such as Microsoft’s .Net, PHP, Java, Python etc. All these technologies or languages are amazing and easier to learn and program with. But PHP is very much like the language that we all speak, English. So it’s much easier to learn.
What Is PHP?
PHP is a server-side scripting language mainly used for web development but also used for general purpose. PHP was created by Rasmus Lerdorf and it initially stood for Personal Home Page but now it stands for PHP: Hypertext Processor.
PHP is the most popular server-side scripting language. As of May 2017, PHP was used on 83% of 10 million most popular websites. Most popular content management systems such as WordPress, Joomla, Drupal, Moodle, SilverStripe etc. are written in PHP. Most popular web applications’ backends are written in PHP such as Facebook, Digg, Dailymotion etc. As of January 2013, PHP was used in more than 240 million websites (39% of those sampled) and was installed on 2.1 million web servers.
How PHP Works?
In simple language, PHP code is embedded into HTML pages or templates. The PHP code is written inside PHP tags that tell the PHP interpreter that the inside code is PHP.
start tag - <?php end tag - ?> <?php echo "Hello world"; ?>
The start tag
<?php shows that the following is the PHP code. And the end tag
?> shows that the code has ended. There are some other tags also but I suggest using these tags. Since this is easier and used by almost all web developers.
Some alternative PHP tags –
<? ?> <? ?> <% %> <%= %>
So we can use these PHP tags to create dynamic pages. Do you know what are the dynamic pages? Let me tell you.
PHP can create dynamic pages. Dynamic pages are formed when the data on the pages update constantly. For example, the blog you’re reading, TheITstuff is a dynamic page. Whenever a post is published, the page automatically gets the post from the database and update it on the page. This page is itself divided into many sections and each section is updated individually. For example, the comment section below this post is updated with new comments, the sidebar and above featured picture is also changed dynamically.
Static pages stay the same until the developer manually changes the page’s HTML to update data.
This also shows that how important a database is to create dynamic pages. In order to create dynamic pages, it’s must have a database and today all the modern web apps talk to database/es in a language that database understands. Some of the most popular database languages are MySQL, SQLite, PostgreSQL etc. We’ll talk more about databases in another article.
Did I mention about a web server? No? It’s not okay. We’ll talk about web server and its installation in another article but for now, all you need to know is that a web server is a software without which you can’t run PHP.
Now don’t think of a web server as a supercomputer with hundreds of terabytes of memory installed. Here the web server simply means a simple and small program that sits on your computer and looks for users requests. As the server receives a request, it processes it and gives the results back to the user browser.
Here we’ll also need to install PHP on the computer so that the PHP interpreter can interpret the PHP code and web server can process the PHP code.
So this is the basics that you need to know as a PHP learner. And obviously, it’s not all. You can follow this series ‘Introduction to PHP’ for more. You can also visit PHP documentation for the most detailed PHP learning. In the next article, I’ll cover the installation of PHP and required software. So see you in the next article. Peace!