PHP Extension and How to Install it on Windows
“PHP is used by 79.2% of all the websites whose server-side programming language we know.”
-W3Techs Report, April 2021
Introduced in 1995, by Rasmus Lerdorf. Earlier PHP stands for Personal Home Page, but now it stands for Recursive Initialism PHP – Hypertext Preprocessor.
Initially, PHP was not deliberately created to be a new programming language. Rasmus Lerdorf said
“I don’t know how to stop it, there was never any intent to write a programming language. I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way.“
And today it has become a successful and most commonly used language.
About PHP
PHP is an open-source language where codes are executed at the server-side by a PHP interpreter, which is why it is also called a Server-side programming language. On the server-side or web server, the output of the PHP interpreter or inputted codes may be of HTML or binary data. And this would be an HTTP response or a part of it.
The PHP interpreter is powered by Zend Engine and it is free software released under PHP License, it does not involve any cost. It is a general-purpose scripting language, especially suited for website development. PHP can also be embedded into HTML. It is a widely used language and can be deployed on most web servers and almost every Operating system.
Special Features of PHP:
- PHP is free to use, it does not involve any cost.
- It is easy to learn and run, as it is a server-side programming language.
- PHP can be used as a standalone language for Graphical Applications and Robotic Drone control.
- It can generate the dynamic web page content.
- It can read, write, create and close files on the server.
- Compatible with almost all type of servers which are available today, that is, Apache, IIS, etc.
- It can also add, modify or delete data available in the database.
- PHP runs on various platforms like Windows, Linux, Unix, Mac OS X, etc.
- It secures data like Bank details on site, Passwords, etc.
Some popular websites using PHP are Facebook, Wikipedia, WordPress, Mailchimp, Dailymotion, Digg, etc.; and the biggest competitor of PHP is “Microsoft’s ASP”.
Data Types
It is important to know that PHP does not depend on any data type. The integers are stored in a platform-dependent range, either as 32, 64, or as a 128-bit signed integer. In specific situations, unsigned integers are converted to signed values.
Integer variables can be assigned with the usage of decimal, both positive and negative, and also with Hexadecimal, Octal, and Binary notations.
Mascot
It is elePHPant with PHP logo on its side, designed by Vincent Pontier, in 1998.
Syntax
PHP syntax and semantics (related meanings) are the text and symbols which are part of the format of a programming language. Syntax talks about the rules that tell us that how the language should be written and understood.
PHP Framework Interop Group (FIG) has created PHP Standards Recommendation (PSR) which assisted in making the language better in terms of standards, since 2009. The modern coding standards are part of PSR-1 (Basic Coding Standard) and PSR-2 (Coding Style Guide).
For example, in pure PHP coding the simplest version of “Happy Reading” may be written like this, with the closing tag ?>
<?phpecho ‘Happy Reading’;?>
The default PHP file extension is .php
A PHP file consists of HTML, CSS, JavaScript, and PHP code. The codes are executed on the server and the result is shown on the browser, in the form of plain HTML.
Let us also know About PHP Extensions
Please find the detail of extension names, launch date, and launched by with their features and details:
PHP 3 | 1997 ByZeevSuraski and Andi Gutmans | Officially launched in June 1998 Public testing began Language’s name changed to Recursive Initialism PHP – Hypertext Preprocessor. |
PHP 4 | May 22, 2000 by the Zend Engine 1.0 | By August 2008 this branch reached to version 4.4.9 But now it is no longer under development. |
PHP 5 | July 1, 2004 By the Zend Engine II | It included new features like object-oriented programming, PHP Data Object (PDO), and others Static Binding was added in version 5.3 Security support ended in December 31, 2018, for PHP 5.6 |
PHP 6 and Unicode | Not Released | Planned to include Native Unicode to support complete PHP by embedding International Components for Unicode (ICU) library Internally presenting text strings as UTF-16 |
PHP 7 | 2014 By Dmitry Stogov, Xinchen Hui, and Nikita Popov | Originally a PHP next generation (phpng) It helped in replacing many error mechanisms of earlier versions with the object-oriented exception Syntax was reworked and allowed the use of the operators ->, [], (),{}, and::, with arbitrary Successfully migrated to Just In Time (JIT) compilation Will support until November 2022 for PHP 7.4 |
PHP 8 | November 26, 2020 | Supported Just In Time (JIT) compilation Introduced Match Expression introduced union types It includes changing, modifying or adding Syntax in many situations Will support until November 2024 for PHP 8.1 |
How to Install PHP on Windows
PHP installation on Windows permits the user to safely create and test websites and applications. It doesn’t let affect the data or systems on the server.
Please follow the following steps for installation:
Step 1: Download the PHP files
Get the latest PHP file on:https://www.php.net/downloads.php
Step 2: Extract the PHP files
Create a new PHP folder in the C drive of your PC and then extract the contents of the downloaded Zip file into it.
Step 3: Configure php.ini
PHP configuration file is named “php.ini” The default settings report all errors and warnings. Next step is to copy C:\php\php.ini-development to C:\php\php.ini.
Then enable any required extension.
The following are available and suitable for most of the websites or application:
extension=curlextension=gdextension=mbstringextension=pdo_mysql
Step 4: Add C:\php to the PATH
For Windows to find PHP file, it is necessary to change the environmental variable to PATH
Click on the Windows Start button, Type “Environment”, then click on “Edit the System Environment Variables”.
Select the Advanced tab à Click on “Environment Variable” à Scroll down to “System Variable” list à Click on “Path” à Then “Edit” à Click “New” and add C:\php:
The installation process is completed here. It is important to know that for older editions of Windows there will be a single text box where paths are separated by a ;(semi-colon).
The system needs to be re-started if any CMD terminals are open.
Configuration and Testing:
To configure PHP in Apache or similar web server software (here we are taking the example of Apache), open the configuration file from C drive in a text editor. Then you need to add the below code at the bottom of it:
# PHP8 modulePHPIniDir “C:/php”LoadModulephp_module “C:/php/php8apache2_4.dll”AddType application/x-httpd-php .php
(Location can be set as per requirement)
Then save it to httpd.conf
Now we need to check the cmd command line:
cd C:\Apache24\binhttpd -t
If there will be no error, then Syntax OK should appear. After this Apache needs to be restarted with httpd.
For testing part of a PHP file please follow below:
A new file to be created with the name index.php in Apache’s root folder and add the following code in it:
<?php phpinfo(); ?>
The last to do is to open your server’s address, there you will find a “PHP version” page, reflecting many PHP and Apache configuration settings.
Now PHP websites or Applications can be created in any sub-folder of C:\Apache24\htdocs
Alternates for Installation
There are also some quicker and simpler ways of installing PHP on Windows. Please find the details below:
- All-in-One Package: It is possible with a single installation file – such as XAMPP, WampServer, and Web.Developer. It also contains Apache, PHP, MySQL, and many other dependencies.
- Linux Virtual Machine: Microsoft Hyper-V (provided in Windows 10 Professional) and Virtual-Box are free hypervisors for PHP installation.
- Use Docker: It creates a wrapper or container for pre-configured applications like PHP. It is considered the best alternate in providing a PHP development environment.
- Windows Subsystem for Linux 2: It is a virtual machine, integrated into Windows for activities like file sharing and “Local Host’ resolution looks flawless. Linux Distros can be installed and then Apache or other webserver software and PHP instructions to be followed.
- If you haven’t knowledge about it so you can choose the best PHP development company for PHP installation.
Final Words
Everything is sorted when the server activates the support for PHP files. When a PHP file is placed in the web directory, the server automatically translates it for the user. The translation does not require any extra tool as PHP is supported by most web hosts because it is free.
Hope the information is helpful for you, All the Best for further coding!
About Author
I am Rashmi, a Content Planner at TechIngenious – a Mobile Application Development Company | Ph.D. in Marketing | I am passionate about Modern Technology and would love to express my knowledge by writing on latest tech trends.Hope you like them, keep following for more.
Great classification that will helps newbies to install php extension on windows. That for sharing with us