PHP is an open source server-side scripting language used by many developers for web development. PHP is also a general-purpose language used to create graphical user interfaces (GUIs). .Finally you can write your first Hello World program in PHP.

What Does PHP Mean?

Active PHP was originally meant for personal websites. But now it has a recursive hypertext preprocessor. (It is repeated in the sense that the first word is itself an abbreviation so that the full meaning is not derived from the abbreviation). The first version of PHP was released 26 years ago. It is now in version 8 which was released in November 2020 but version 7 is still the most used: PHP running on the Zend engine is the most popular. There are other applications like Parrot HPVM (Hip-Hop Virtual Machine) and Hip-Hop created by Facebook. PHP is mainly used to build web servers. It runs in a browser and can be used on the command line. So if you dont want to display the output of your code in the browser you can display it in the terminal.

Advantages of PHP

PHP has many advantages that make it popular and has been the language for web servers for over 15 years. Here are some advantages of PHP.

  • Cross-Platform: PHP is platform-independent. You don’t have to have a particular OS to use it because it runs on every platform, whether it’s Mac, Windows, or Linux.
  • Open Source: PHP is open source. The original code is available to anyone who wants to build on it. This is one of the reasons why Laravel is one of the most popular frameworks.
  • Easy to learn: PHP is not difficult for beginners to learn. If you already have programming knowledge you can go for it beautifully.
  • PHP Sync with All Databases: You can easily connect PHP with all relational and non-relational databases. It can instantly connect to MySQL Postgress MongoDB or any other database.
  • A supportive community. PHP has a very supportive online community. The official documentation provides instructions on how to use the features and can easily solve your problems if you get stuck.

Who Uses PHP

Many established companies and tech giants use PHP to run their servers and do many amazing things.

  • Facebook: Facebook uses PHP to power its site. In turn, the company contributed to the community by creating an implementation known as Hip Hop for PHP.
  • Wikipedia: one of the world’s largest sources of information on any topic, Wikipedia is built in PHP.
  • Content Management Systems (CMS): Worlds most popular content management system WordPress is based on PHP. Other content management systems like Drupal Joomla and Magento are based on PHP. Shopify also runs on PHP.
  • Web hosting platforms: Many web hosting platforms such as BlueHost SiteGround and HugoHost use PHP to run their hosting servers.

Is PHP Dying?

Currently the debate about whether PHP is degenerate is rampant. This is due to the emergence and growing popularity of other suitable server side languages โ€‹โ€‹like JavaScript (Node JS) Python Golang etc. This has actually led to a lot of funny memes for PHP

But is PHP really dying? The answer is no. Despite some people bashing on it and the claims of decline, PHP is still used to run the servers of almost 80% of all websites today. So, if you visit 10 websites a day, there’s a chance that 8 of them use PHP.

In terms of job availability, PHP ranks better than a lot of other programming languages on the job platform Indeed. A lot of PHP developers make a good living making WordPress themes and plugins every year โ€“ the average PHP developer in the US makes $86,000 per year.

php-jobs

How to Write Your First Hello World Program in PHP

Now that you understand PHP and its benefits its time to write your first Hello World program in PHP. First you need to install PHP on your local computer. This can be achieved by installing a XAMP (Cross-Platform Apache MySQL and PHP) or WAMP (Windows Apache MySQL and PHP) server. XAMP works on all operating systems WAMP works only on Windows. I am using WAMP. Open your WAMP or XAMP server and make sure all services are running. If youre using WAMP youll see the WAMP logo in green on your taskbar.

wamp-running

Open your C drive and browse to the WAMP server installation folder. In my case it was wamp64.

wampfolder

Open the installation directory, and then the www folder.

wwwfolder

Create a folder right there and name it whatever you want, then open up the folder with your code editor.

Create an index.php file and paste in the following code:

<?php

echo "Hello World";

?>

You can also put your โ€œHello Worldโ€ text in a variable, then use the echo system to display it in the browser.

In PHP, you can declare a variable with the dollar sign ($). Your statements, apart from the last one, must also be terminated by a semi-colon.

<?php

$greeting = "Hello World";
echo $greeting

?>

To run your code in the browser, open up the browser and write this in the address bar localhost/the-folder-of-your-php-file/php-file.php, then hit enter.

Make sure your WAMP or XAMP server is running, otherwise it wonโ€™t work.

hello-world

You can see that the code successfully ran in the browser, because I got the file path right.

Another beautiful thing about PHP is that you can embed it in HTML. You can do it like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PHP Code</title>
</head>
<body>
    <h1> This is the result of a PHP Code embedded in HTML</h1>

        <?php 
            $greeting = "Hello World";
            $campers = "Hello Campers";

            echo $greeting;
            echo "<br>";
            echo $campers
        ?>
</body>
</html>
php-in-html

Conclusion

PHP is a related and widely used language in web development. Despite the ridicule and controversy over whether its still valuable PHP developers continue to make a decent living using the language. So it doesnt look like PHP is coming soon..

Search

About

Our professional services offered by Assignment Xperts encompass a comprehensive range of digital marketing solutions, all tailored to cater to the diverse needs of our clientele. Our expertise covers: Content Writing: This involves the skillful creation of engaging material that effectively communicates brand messages and captivates target audiences. Video Editing: We specialize in producing visually appealing videos aimed at enhancing brand awareness across various media platforms. Social Media Management (SMM): This entails the strategic management of social media platforms to amplify visibility and drive conversions. Web Development: Our team excels in the development of aesthetically pleasing, performance-optimized websites designed for easy navigation. Google Ads: We implement targeted campaigns to bolster online presence and maximize return on investment. PPC Campaigns: Our services encompass the creation and oversight of advertisements tailored to attract specific traffic and optimize investment. Logo Designing: We specialize in the creation of unique logos that perfectly complement and represent a brand’s identity. Branding: This involves the strategic establishment of a recognizable brand and the fostering of customer adherence. Infrastructure Solutions: We offer comprehensive IT assistance.