PHP – Introduction
PHP is one of the most popular server-side scripting languages in existence today. If you have a web hosting account to run your personal blog or website, I can guarantee that PHP is already installed on the same server.
PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management system (CMS) and frameworks. PHP code is usually processed by a PHP interpreter powered by the Zend Engine
- PHP originally stood for Personal Home Page, which is now officially known as ‘Hypertext Preprocessor’ was released in the year 1995 by Rasmus Lerdorf.
- PHP is free software, Open Source released under the PHP License.
- It is possible to use PHP in almost every operating system. PHP can be used in all major operating systems including Linux, Microsoft Windows and Mac OS X.
- PHP was originally designed to create dynamic and more interactive web pages. It is the most widely-used, open-source and general-purpose scripting language.
- PHP is installed on over 20 million websites and 1 million web servers.
- 75% of Web 2.0 sites are built in PHP. PHP is used by 81.7% of all the websites whose server-side programming language we know.
- Some of the biggest online brands, such as Facebook, Digg, Flickr, Technorati, and Yahoo! are powered by PHP.
PHP Development Tools
We need the following major tools necessary to develop PHP based application –
Apache Server– A web server that delivers content using HTTP, over the World Wide Web.
MySQL / Mariadb Database – This is where you will store your information.
PHP – is a widely used language to produce or developed dynamic web pages.
Various software bundles are there in PHP to fulfill above requirements-
LAMP – Linux, Apache, MySQL, and PHP
WAMP – Window, Apache, MySQL, and PHP
MAMP / DAMP – macOS / Mac OS X, Apache, MySQL, & PHP
XAMPP – Cross-Platform (X), Apache (A), MariaDB (M), PHP (P) and Perl (P)
From the above list of bundles I recommend to download and Install XAMPP
To work with XAMPP bundle, following steps are required-
-Download & Install XAMPP Latest version.
-Run XAMPP Control Panel, and start running Apache and MySQL Services.
-To test installation of your Apache server, open your Web browser and type http://localhost/
– If your installation was successful, you will see an Apache “success” page in your browser.
PHP IDE / Code Editor
There are various code editors and IDE to work with PHP Environment.
You may use Notepad++, Dreamweaver, NetBeans or sublime text as PHP Code editor.
Customizing Your Installation
The main configuration file for PHP is php.ini; it can be found in the root directory of XAMPP like c:\xampp\apache\php.ini
Some major settings available in php.ini :
short_open_tag: Allows short tags to be parsed (<? and ?>
output_buffering: Allows header lines to be sent after HTML has already been sent to the server. The default is “Off,”
max_execution_time: Sets the limit for how long a script can take to run or execute
max_input_time Sets the limit for how long a script can take to parse the data.
memory_limit Sets the limit for how much memory a script can use to run in MB.
file_uploads: Enables Web site visitors to upload files to your server.
upload_max_filesize: Sets the limit for how large an uploaded file may be, in MB.
mysql.allow_persistent: Determines whether or not a persistent connection can be established with the MySQL server.
mysql.max_persistent: Sets the limit of how many persistent connections are allowed.
PHP programs are written using a text editor, such as Notepad or Dreamweaver, just like HTML pages. We use .php extension to make php file. This extension tells to the server that it needs to parse the PHP code before sending the HTML Response to the Web browser as PHP code are invisible to the people while visiting on your site.
The Rules of PHP Syntax
You should always keep in mind these rules while working with PHP:
– PHP is denoted in the page with opening and closing tags, as follows: <?php and ?>
– PHP lines end or terminates with a semicolon
You can also make program easy by adding comments in your program using double slashes (//) or /* and */