Programming languages are formal systems designed for expressing computations. They are used to instruct computers and create software applications. There are numerous programming languages, each with its own syntax, semantics, and purposes.

Types of programming languages

  1. Domain specific like SQL

  2. General purpose like C++, Java, Python, PHP.

The domain-specific languages are used within specific application domains. For example, SQL is a domain-specific language. It’s used mainly for querying data from relational databases. And SQL cannot be used for other purposes.

On the other hand, PHP is a general-purpose language because PHP can develop various applications but it is mainly used in web development.

What can PHP do ?

PHP has two main applications :

  • Server side scripting - developing dynamic websites

  • Command line scripting - like python, we can run PHP script from command line to send mails or some admin tasks.

How PHP works ?

How PHP works image

To Work with PHP we need to have following software installed

PHP

Note: To get started you can also try FrankenPHP

After installation you will see something like this in your terminal

govind@debian:~$ php -v
PHP 8.3.11 (cli) (built: Sep  2 2024 15:06:27) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies

Running PHP code

First of all make a file named index.php and write some code in it as given below

<?php
    echo "Hello world";

There is 2 ways by which you can run PHP code

  • Serve on the web
  php -S localhost:8000

now go to the browser and type localhost:8000 in address bar

  • On the Command line
  php index.php

Conclusion

PHP continues to be a powerful and versatile language for both web and command-line applications. Its ability to dynamically generate content, combined with an extensive ecosystem of libraries and frameworks, makes it a popular choice for developers worldwide.