PHP: getting started with Php.
- Ameni OUERTANI
- Oct 27, 2018
- 3 min read
Updated: Oct 30, 2018

What is PHP?
"PHP* is a popular general-purpose scripting language that is especially suited to web development.
Fast, flexible and pragmatic, PHP powers everything from your blog to the most popular websites in the world."
*:Php (recursive acronym for PHP: Hypertext Preprocessor) .
Example #1 An introductory example:
<!DOCTYPE HTML> <html> <head> <title>Example1</title> </head> <body>
<?php echo "Hi, I'm a PHP script!"; ?>
</body> </html>
Php does not use lots of commands to output HTML, PHP pages contain HTML with embedded code (in this case, our output is "Hi, I'm a PHP script!"). The PHP code is enclosed in special <?php and ?> that allow you to jump into and out of "PHP mode".
What distinguishes PHP from something like client-side JavaScript is that the code is executed on the server, generating HTML which is then sent to the client. The client would receive the results of running that script, but would not know what the underlying code was.
What can PHP do?
Anything!! PHP is mainly focused on server-side scripting, so you can do anything any other CGI program* can do, such as collect form data, generate dynamic page content, or send and receive cookies and much more.
* CGI is the abbreviation of Common Gateway Interface. It is a specification for transferring information between a World Wide Web server and a CGI program. A CGI program is any program designed to accept and return data that conforms to the CGI specification. The program could be written in any language, including C, Perl, Java, or Visual Basic.
There are three main areas where PHP scripts are used:
Server-side scripting: This is the most traditional and main target field for PHP. You need three things to make this work: the PHP parser (CGI or server module), a web server and a web browser. You need to run the web server, with a connected PHP installation. You can access the PHP program output with a web browser, viewing the PHP page through the server. All these can run on your home machine if you are just experimenting with PHP programming. See the official installation instructions from their site for more information.
Command line scripting: You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows).
Writing desktop applications: PHP is probably not the very best language to create a desktop application with a graphical user interface, but if you know PHP very well, and would like to use some advanced PHP features in your client-side applications you can also use PHP-GTK to write such programs.
PHP can be used on all major operating systems, including Linux, many Unix variants, Microsoft Windows, macOS and probably others. PHP also has support for most of the web servers today. This includes Apache, IIS, and many others.
So with PHP, you have the freedom of choosing an operating system and a web server. Furthermore, you also have the choice of using procedural programming or object oriented programming (OOP), or a mixture of them both.
One of the strongest and most significant features in PHP is: its support for a wide range of databases. Writing a database-enabled web page is incredibly simple using one of the database specific extensions (e.g., for mysql), or using an abstraction layer like PDO, or connect to any database supporting the Open Database Connection standard via the ODBC extension.
PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows) and countless others. You can also open raw network sockets and interact using any other protocol.
Comments