PHP on cloud

1-click AWS Deployment    1-click Azure Deployment

Overview

PHP started out as a small open source project that evolved as more and more people found out how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.PHP is the most popular scripting language on the web. Without PHP Facebook, Yahoo, Google wouldn’t have exist. The course is geared to make you a PHP pro. Once you digest all basics, the course will help you create your very own Opinion Poll application.PHP is a server side scripting language. that is used to develop Static websites or Dynamic websites or Web applications. PHP stands for Hypertext Pre-processor, that earlier stood for Personal Home Pages.PHP scripts can only be interpreted on a server that has PHP installed.The client computers accessing the PHP scripts require a web browser only.A PHP file contains PHP tags and ends with the extension “.php”.

  • PHP is a recursive acronym for “PHP: Hypertext Preprocessor”.
  • PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.
  • It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.
  • PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix side. The MySQL server, once started, executes even very complex queries with huge result sets in record-setting time.
  • PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time.
  • PHP is forgiving: PHP language tries to be as forgiving as possible.
  • PHP Syntax is C-Like.

Common uses of PHP

  • PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
  • PHP can handle forms, i.e. gather data from files, save data to a file, through email you can send data, return data to the user.
  • You add, delete, modify elements within your database through PHP.
  • Access cookies variables and set cookies.
  • Using PHP, you can restrict users to access some pages of your website.
  • It can encrypt data.

Characteristics of PHP

Five important characteristics make PHP’s practical nature possible −

  • Simplicity
  • Efficiency
  • Security
  • Flexibility
  • Familiarity

What is a Scripting Language?

A script is a set of programming instructions that is interpreted at runtime.A scripting language is a language that interprets scripts at runtime. Scripts are usually embedded into other software environments.The purpose of the scripts is usually to enhance the performance or perform routine tasks for an application.Server side scripts are interpreted on the server while client side scripts are interpreted by the client application.

PHP is a server side script that is interpreted on the server while JavaScript is an example of a client side script that is interpreted by the client browser. Both PHP and JavaScript can be embedded into HTML pages.

Programming Language Vs Scripting Language

Programming language Scripting language
Has all the features needed to develop complete applications. Mostly used for routine tasks
The code has to be compiled before it can be executed The code is usually executed without compiling
Does not need to be embedded into other languages Is usually embedded into other software environments.

What does PHP stand for?

PHP means – Personal Home Page, but it now stands for the recursive backronym PHP: Hypertext Preprocessor.PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management system and web frameworks.

Php Syntax

 

What is PHP? Write your first PHP Program

A PHP file can also contain tags such as HTML and client side scripts such as JavaScript.

  • HTML is an added advantage when learning PHP Language. You can even learn PHP without knowing HTML but it’s recommended you at least know the basics of HTML.
  • Database management systems DBMS for database powered applications.
  • For more advanced topics such as interactive applications and web services, you will need JavaScript and XML.

The flowchart diagram shown below illustrates the basic architecture of a PHP web application and how the server handles the requests.

What is PHP? Write your first PHP Program

Why use PHP?

You have obviously heard of a number of programming languages out there; you may be wondering why we would want to use PHP as our poison for the web programming. Below are some of the compelling reasons.

  • PHP is open source and free.
  • Short learning curve compared to other languages such as JSP, ASP etc.
  • Large community document
  • Most web hosting servers support PHP by default unlike other languages such as ASP that need IIS. This makes PHP a cost effective choice.
  • PHP is regular updated to keep abreast with the latest technology trends.
  • Other benefit that you get with PHP is that it’s a server side scripting language; this means you only need to install it on the server and client computers requesting for resources from the server do not need to have PHP installed; only a web browser would be enough.
  • PHP has in built support for working hand in hand with MySQL; this doesn’t mean you can’t use PHP with other database management systems. You can still use PHP with
    • Postgres
    • Oracle
    • MS SQL Server
    • ODBC etc.
  • PHP is cross platform; this means you can deploy your application on a number of different operating systems such as windows, Linux, Mac OS etc.

What is PHP used for & Market share

In terms of market share, there are over 20 million websites and application on the internet developed using PHP scripting language.This may be attributed to the points raised above;The diagram below shows some of the popular sites that use PHP

What is PHP? Write your first PHP Program

PHP vs Asp.Net VS JSP VS CFML

ASP – Active Server Pages, JSP – Java Server Pages, CFML – Cold Fusion Markup language The table below compares the various server side scripting languages with PHP.

PHP File Extensions

File extension and Tags In order for the server to identify our PHP files and scripts, we must save the file with the “.php” extension. Older PHP file extensions include

  • .phtml
  • .php3
  • .php4
  • .php5
  • .phps

PHP was designed to work with HTML, and as such, it can be embedded into the HTML code.

What is PHP? Write your first PHP Program

You can create PHP files without any html tags and that is called Pure PHP file .

The server interprets the PHP code and outputs the results as HTML code to the web browsers.

In order for the server to identify the PHP code from the HTML code, we must always enclose the PHP code in PHP tags.

A PHP tag starts with the less than symbol followed by the question mark and then the words “php”.

PHP is a case sensitive language, “VAR” is not the same as “var”.

The PHP tags themselves are not case-sensitive, but it is strongly recommended that we use lower case letter. The code below   illustrates the above point.

<?php … ?>

We will be referring to the PHP lines of code as statements. PHP statements end with a semi colon (;). If you only have one statement, you can omit the semi colon. If you have more than one statement, then you must end each line with a semi colon. For the sake of consistency, it is recommended that you always end your statement(s) with a semi colon.  PHP scripts are executed on the server. The output is returned in form of HTML.

 

PHP Hello world

The program shown below is a basic PHP application that outputs the words “Hello World!” When viewed in a web browser.

<?php
echo "Hello world";
?>

Output:

Hello world

PHP – Environment Setup

In order to develop and run PHP Web pages three vital components need to be installed on your computer system.

  • Web Server − PHP will work with virtually all Web Server software, including Microsoft’s Internet Information Server (IIS) but then most often used is freely available Apache Server.
  • Database − PHP will work with virtually all database software, including Oracle and Sybase but most commonly used is freely available MySQL database
  • PHP Parser − In order to process PHP script instructions a parser must be installed to generate HTML output that can be sent to the Web Browser.

PHP Parser Installation

Before you proceed it is important to make sure that you have proper environment setup on your machine to develop your web programs using PHP.

Type the following address into your browser’s address box.

http://127.0.0.1/info.php

If this displays a page showing your PHP installation related information then it means you have PHP and Webserver installed properly. Otherwise you have to follow given procedure to install PHP on your computer.

PHP – Installation on Windows with IIS

The Windows server installation of PHP running IIS is much simpler than on Unix, since it involves a precompiled binary rather than a source build.

If you plan to install PHP over Windows, then here is the list of prerequisites −

  • A working PHP-supported Web server. Under previous versions of PHP, IIS/PWS was the easiest choice because a module version of PHP was available for it; but PHP now has added a much wider selection of modules for Windows.
  • A correctly installed PHP-supported database like MySQL or Oracle etc. (if you plan to use one)
  • The PHP Windows binary distribution .
  • A utility to unzip files (search http://download.cnet.com for PC file compression utilities)

Now here are the steps to install Apache and PHP5 on your Windows machine. If your PHP version is different then please take care accordingly.

  • Extract the binary archive using your unzip utility; C:\PHP is a common location.
  • Copy some .dll files from your PHP directory to your systems directory (usually C:\Winnt\System32). You need php5ts.dll for every case. You will also probably need to copy the file corresponding to your Web server module – C:\PHP\Sapi\php5isapi.dll. It’s possible you will also need others from the dlls subfolder – but start with the two mentioned above and add more if you need them.
  • Copy either php.ini-dist or php.ini-recommended (preferably the latter) to your Windows directory (C:\Winnt or C:\Winnt40), and rename it php.ini. Open this file in a text editor (for example, Notepad). Edit this file to get configuration directives; We highly recommend new users set error reporting to E_ALL on their development machines at this point. For now, the most important thing is the doc_root directive under the Paths and Directories section.make sure this matches your IIS Inetpub folder (or wherever you plan to serve out of).
  • Stop and restart the WWW service. Go to the Start menu → Settings → Control Panel → Services. Scroll down the list to IIS Admin Service. Select it and click Stop. After it stops, select World Wide Web Publishing Service and click Start. Stopping and restarting the service from within Internet Service Manager will not suffice. Since this is Windows, you may also wish to reboot.
  • Open a text editor. Type: <?php phpinfo(); ?>. Save this file in your Web server’s document root as info.php.
  • Start any Web browser and browse the file.you must always use an HTTP request (http://www.testdomain.com/info.php or http://localhost/info.php or http://127.0.0.1/info.php) rather than a filename (/home/httpd/info.php) for the file to be parsed correctly.You should see a long table of information about your new PHP installation message Congratulations!

PHP – Frame Works

Frame Work is collection of software or program, that trigger off easy coding and implementing the code. It helps to programmer to achieve goals in short period of time. If PHP code is integrated with frame works, you can do anything with php coding skills.

Some of frame works

FuelPHP

Fuel PHP works based on Model View Control and having innovative plug ins. FuelPHP supports router based theory where you might route directly to a nearer the input uri, making the closure the controller and giving it control of further execution.

FuelPHP

CakePHP

Cake PHP is a great source to build up simple and great web application in an easy way. Some great feature which are inbuilt in php are input validation, SQL injection prevention that keeps you application safe and secure.

Features

  • Build Quickly
  • No need to configure
  • MIT licence
  • MVC Model
  • Secure

cake_php

FlightPHP

Flight PHP is very helpful to make RESTful web services and it is under MIT licence.

flight_php

Symfony

Symfony is for highly professional developer to build websites with PHP components such as Drupal, PHPBB, laravel, eX, OROCRM and piwik.

symfony_php

yiiFramework

YiiFramework works based on web 2.0 with high end security. It included input Validation, output filtering, and SQL injection.

yiiFramework_php

Laravel

Laravel is most useful for RESRful Routing and light weight bled tempting engine. Laravel has integrated with some of great components of well tested and reliable code.

laravel_php

Zend

Zend is Modern frame work for performing high end web applications. This works based on Cryptographic and secure coding tools.

zend_php

Codeigniter

Codeigiter is simple to develop small fool print for developer who need simple and elegant tool kit to create innovative web applications.

codeigniter_php

Phalcon PHP

Pholcon PHP works based on MVC and integrated with innovative architecture to do perform faster.

phaicon_php

PHPixie

PHPixie works based on MVC and designed for fast and reliability to develop web sites.

phpixie_php

Agavi

Agavi is a powerful frame work and follows MVC model. It enables to developer to write clean and maintainable code.

agavi_php

 

Core PHP vs Frame Works PHP

We assume that Core PHP means solving a Mathematical problem by using paper and pen. Frame work means solving Mathematical problem by using a calculator.

Core PHP-Solving Mathematical Problem

Only some students can achieve results by using paper and pen as same as in PHP. Only a few of the developers can write the code in an easy way and reliable format.

Framework – Solving Mathematical problem

Everyone can achieve the result by using the calculator as same as in PHP. Even beginners can write the code in easy way and reliable format.

The main problem with core PHP is when developers write own logic, it is difficult to make it out for the result so most of the developers are choosing innovative frameworks.

Frame Work

Most of the frameworks are reliability, consistence and time saver. Some of the innovative frameworks are having the rich set of functionalities, so developer no need to write whole code, Developers needs to access the code by using framework and develop a PHP web application. Frameworks don’t give the solutions for bad code writers, but it gives reliability while writing code.

Enhance Projects

Everyone wants to move into sophisticated technologies. If any website or web applications have developed in Core PHP, it is difficult to enhance the website components, but if website or web applications has developed in Frame Work PHP, it is very easy to enhance the features.

Has Core PHP Been BAD?

It’s not at all bad. Core PHP helps you write the code and understand the code. when the developer at begin stage, we strongly recommended to learn Core PHP, cause we don’t want to see you as a bad developer. According to World theory, easy always gives best result with strong base. As per the world theory, if you know core PHP, you would reach your goal by using framework PHP.

PHP Form Handling

The PHP superglobals $_GET and $_POST are used to collect form-data.


PHP – A Simple HTML Form

The example below displays a simple HTML form with two input fields and a submit button:

Example

<html>
<body><form action=”welcome.php” method=”post”>
Name: <input type=”text” name=”name”><br>
E-mail: <input type=”text” name=”email”><br>
<input type=”submit”>
</form></body>
</html>

When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named “welcome.php”. The form data is sent with the HTTP POST method.

To display the submitted data you could simply echo all the variables. The “welcome.php” looks like this:

<html>
<body>Welcome <?php echo $_POST[“name”]; ?><br>
Your email address is: <?php echo $_POST[“email”]; ?></body>
</html>

The output could be something like this:

Welcome John
Your email address is john.doe@example.com

The same result could also be achieved using the HTTP GET method:

Example

<html>
<body><form action=”welcome_get.php” method=”get”>
Name: <input type=”text” name=”name”><br>
E-mail: <input type=”text” name=”email”><br>
<input type=”submit”>
</form></body>
</html>

and “welcome_get.php” looks like this:

<html>
<body>Welcome <?php echo $_GET[“name”]; ?><br>
Your email address is: <?php echo $_GET[“email”]; ?></body>
</html>

The code above is quite simple. However, the most important thing is missing. You need to validate form data to protect your script from malicious code.

PHP – Form Introduction

 

Dynamic Websites

The Websites provide the functionalities that can use to store, update, retrieve, and delete the data in a database.

What is the Form?

A Document that containing black fields, that the user can fill the data or user can select the data.Casually the data will store in the data base

Example

Below example shows the form with some specific actions by using post method.

<html>
   
   <head>
      <title>PHP Form Validation</title>
   </head>
   
   <body>
      <?php
         
         // define variables and set to empty values
         $name = $email = $gender = $comment = $website = "";
         
         if ($_SERVER["REQUEST_METHOD"] == "POST") {
            $name = test_input($_POST["name"]);
            $email = test_input($_POST["email"]);
            $website = test_input($_POST["website"]);
            $comment = test_input($_POST["comment"]);
            $gender = test_input($_POST["gender"]);
         }
         
         function test_input($data) {
            $data = trim($data);
            $data = stripslashes($data);
            $data = htmlspecialchars($data);
            return $data;
         }
      ?>
   
      <h2>Tutorials Point Absolute classes registration</h2>
      
      <form method = "post" action = "/php/php_form_introduction.htm">
         <table>
            <tr>
               <td>Name:</td> 
               <td><input type = "text" name = "name"></td>
            </tr>
            
            <tr>
               <td>E-mail:</td>
               <td><input type = "text" name = "email"></td>
            </tr>
            
            <tr>
               <td>Specific Time:</td>
               <td><input type = "text" name = "website"></td>
            </tr>
            
            <tr>
               <td>Class details:</td>
               <td><textarea name = "comment" rows = "5" cols = "40"></textarea></td>
            </tr>
            
            <tr>
               <td>Gender:</td>
               <td>
                  <input type = "radio" name = "gender" value = "female">Female
                  <input type = "radio" name = "gender" value = "male">Male
               </td>
            </tr>
            
            <tr>
               <td>
                  <input type = "submit" name = "submit" value = "Submit"> 
               </td>
            </tr>
         </table>
      </form>
      
      <?php
         echo "<h2>Your Given details are as :</h2>";
         echo $name;
         echo "<br>";
         
         echo $email;
         echo "<br>";
         
         echo $website;
         echo "<br>";
         
         echo $comment;
         echo "<br>";
         
         echo $gender;
      ?>
      
   </body>
</html>

It will produce the following result −

Form Introduction

Required field will check whether the field is filled or not in the proper way. Most of cases we will use the * symbol for required field.

PHP – Validation Example

What is Validation ?

Validation means check the input submitted by the user. There are two types of validation are available in PHP. They are as follows −

  • Client-Side Validation − Validation is performed on the client machine web browsers.
  • Server Side Validation − After submitted by data, The data has sent to a server and perform validation checks in server machine.

Some of Validation rules for field

Field Validation Rules
Name Should required letters and white-spaces
Email Should required @ and .
Website Should required a valid URL
Radio Must be selectable at least once
Check Box Must be checkable at least once
Drop Down menu Must be selectable at least once

Valid URL

Below code shows validation of URL

$website = input($_POST["site"]);

if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i",$website)) {
   $websiteErr = "Invalid URL"; 
}

Above syntax will verify whether a given URL is valid or not. It should allow some keywords as https, ftp, www, a-z, 0-9,..etc..

Valid Email

Below code shows validation of Email address

$email = input($_POST["email"]);

if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
   $emailErr = "Invalid format and please re-enter valid email"; 
}

Above syntax will verify whether given Email address is well-formed or not.if it is not, it will show an error message.

Example

Example below shows the form with required field validation

<html>
   
   <head>
      <style>
         .error {color: #FF0000;}
      </style>
   </head>
   
   <body>
      <?php
         // define variables and set to empty values
         $nameErr = $emailErr = $genderErr = $websiteErr = "";
         $name = $email = $gender = $comment = $website = "";
         
         if ($_SERVER["REQUEST_METHOD"] == "POST") {
            if (empty($_POST["name"])) {
               $nameErr = "Name is required";
            }else {
               $name = test_input($_POST["name"]);
            }
            
            if (empty($_POST["email"])) {
               $emailErr = "Email is required";
            }else {
               $email = test_input($_POST["email"]);
               
               // check if e-mail address is well-formed
               if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                  $emailErr = "Invalid email format"; 
               }
            }
            
            if (empty($_POST["website"])) {
               $website = "";
            }else {
               $website = test_input($_POST["website"]);
            }
            
            if (empty($_POST["comment"])) {
               $comment = "";
            }else {
               $comment = test_input($_POST["comment"]);
            }
            
            if (empty($_POST["gender"])) {
               $genderErr = "Gender is required";
            }else {
               $gender = test_input($_POST["gender"]);
            }
         }
         
         function test_input($data) {
            $data = trim($data);
            $data = stripslashes($data);
            $data = htmlspecialchars($data);
            return $data;
         }
      ?>
     
      <h2>Absolute classes registration</h2>
     
      <p><span class = "error">* required field.</span></p>
     
      <form method = "post" action = "<?php 
         echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
         <table>
            <tr>
               <td>Name:</td>
               <td><input type = "text" name = "name">
                  <span class = "error">* <?php echo $nameErr;?></span>
               </td>
            </tr>
           
            <tr>
               <td>E-mail: </td>
               <td><input type = "text" name = "email">
                  <span class = "error">* <?php echo $emailErr;?></span>
               </td>
            </tr>
           
            <tr>
               <td>Time:</td>
               <td> <input type = "text" name = "website">
                  <span class = "error"><?php echo $websiteErr;?></span>
               </td>
            </tr>
            
            <tr>
               <td>Classes:</td>
               <td> <textarea name = "comment" rows = "5" cols = "40"></textarea></td>
            </tr>
            
            <tr>
               <td>Gender:</td>
               <td>
                  <input type = "radio" name = "gender" value = "female">Female
                  <input type = "radio" name = "gender" value = "male">Male
                  <span class = "error">* <?php echo $genderErr;?></span>
               </td>
            </tr>
				
            <td>
               <input type = "submit" name = "submit" value = "Submit"> 
            </td>
				
         </table>
			
      </form>
      
      <?php
         echo "<h2>Your given values are as:</h2>";
         echo $name;
         echo "<br>";
         
         echo $email;
         echo "<br>";
         
         echo $website;
         echo "<br>";
         
         echo $comment;
         echo "<br>";
         
         echo $gender;
      ?>
   
   </body>
</html>

It will produce the following result −

Validation Example

Advantages and Disadvantages of PHP Frameworks:

Advantages of Using PHP Frameworks

 

Speed up custom web application development

Nowadays, PHP programmers have to write web applications based on complex business requirements. Likewise, they have to explore ways to make the web application deliver richer user experience. The tools, features, and code snippets provided by PHP frameworks help developers to accelerate custom web application development.

Simplify web application maintenance

Unlike other programming languages, PHP does not emphasize on code readability and maintainability. The PHP frameworks simplify web application development and maintenance by supporting model-view-controller (MVC) architecture. The developers can take advantage of MVC architecture to divide a web application into models, views and controllers. They can use a MVC framework for PHP to keep the application’s user interface and business logic layers separated.

No need to write additional code

PHP, unlike other programming languages, does not allow programmers to express concepts without writing longer lines of code. Hence, the PHP programmers have to write lengthy and complex code while adding features or functionality to a website. The PHP frameworks reduce coding time significantly by providing code generation feature. The code generation features provided by certain PHP frameworks enable programmers to keep the source code of web application clean and maintainable.

Work with databases more efficiently

Most PHP frameworks allow programmers to work with a number of widely used relational databases. Some frameworks further simplify database operations by providing object relational mapping (ORM) systems. The programmers can take advantage of the ORM systems to perform database operations without writing lengthy SQL code. The ORMs even allows programmers to write object code directly in PHP programming language.

Automate common web development tasks

While building a web application, developers have to perform a number of tasks in addition to writing code. Some of these common web development tasks require programmers to invest additional time and effort. The functions and tools provided by PHP frameworks help developers to automate common web development tasks like caching, session management, authentication, and URL mapping.

Protect websites from targeted security attacks

PHP is considered to be one of the most unsecured programming languages. Often programmers have to explore ways to protect the PHP applications from various security attacks. The built-in security features and mechanisms provided by PHP framework make it easier for developers to protect the website from existing and emerging security threats. Also, the PHP web developers can easily prevent common security threats like SQL injections, cross-site request forgery, and data tampering.

Perform unit testing efficiently

While building a custom web application, developers have to perform unit testing regularly to evaluate its individual units or components. A large percentage of web developers use PHPUnit to perform unit tests quickly and efficiently. In addition to being an object-oriented unit testing framework for PHP, PHPUnit further helps developers to write and run unit tests by providing coding assistance. Many PHP frameworks support PHPUnit natively, and enable programmers to perform unit testing smoothly.

No need to increase web development cost

As an open source server-side programming language, PHP helps users to curtail web development cost significantly. The developers also have option to choose from several open source web frameworks for PHP. They can even avail the features and tools provided by these open source PHP frameworks speed up custom web application development without increasing project overheads.

Disadvantages of Using PHP Frameworks:

Programmers need to learn PHP frameworks instead of PHP

The PHP frameworks enable programmers to add functionality to a web application without writing additional code. But the programmers have to put some time and effort to learn the PHP framework. They can even learn and use certain frameworks without being proficient in PHP coding.

Quality of PHP frameworks differs

Most widely used PHP frameworks are open source and free. Hence, the web developers can take advantage of these web frameworks without increasing the project cost. But the community strength of individual frameworks differs. Hence, some PHP frameworks lack prompt and adequate support.

Lack of option to modify core behavior

In addition to proving a basic structure for web application development, the PHP frameworks further accelerate custom web application development. But the developers still lack any option to make changes to the core behavior of these frameworks. Some frameworks even requirements developers to use specific tools or adopt a particular web development pattern.

Affect Speed and performance of websites

Most PHP frameworks come with robust features and tools to accelerate development of large and complex websites. But web developers may not need these advanced features while building small or simple web applications. Also, these additional features often impact the performance and speed of websites adversely.

On the whole, the web developers have option to choose from several full-stack and micro web frameworks for PHP. But the widely used PHP frameworks differ from each other in the category of functionality, usability, and performance. Also, each PHP framework has its own pros and cons. That is why, the web developers must keep in mind precise project requirements while assessing advantages and disadvantages of using PHP frameworks.

-PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language. Originally created by Rasmus Lerdorf in 1994,the PHP reference implementation is now produced by The PHP Group. PHP originally stood for Personal Home Page, but it now stands for the recursive backronym PHP: Hypertext Preprocessor.

PHP code may be embedded into HTML code, or it can be used in combination with various web template systems, web content management system and web frameworks. PHP code is usually processed by a PHP interpreter implemented as amodule in the web server or as a Common Gateway Interface (CGI) executable. The web server combines the results of the interpreted and executed PHP code, which may be any type of data, including images, with the generated web page. PHP code may also be executed with a command-line interface (CLI) and can be used to implement standalone graphical applications.

The standard PHP interpreter, powered by the Zend Engine, is free software released under the PHP License. PHP has been widely ported and can be deployed on most web servers on almost every operating system and platform, free of charge.
The PHP language evolved without a written formal specification or standard until 2014, leaving the canonical PHP interpreter as a de facto standard. Since 2014 work has gone on to create a formal PHP specification.

During the 2010s there have been increased efforts towards standardisation and code sharing in PHP applications by projects such as PHP-FIG in the form of PSR-initiatives as well as Composer dependency manager and the Packagist repository.

PHP on cloud for AWS

Features

PHP | Unique Features

As PHP can do anything related to server-side programming which contains the backend of any web page,
it holds a lot of unique features within it. The main purpose of PHP design is web development.

Let us look into some of the unique features of PHP:

  • Simple, Familiar and ease of use: Its popularly known for its simplicity, familiarity and easy to learn the language as the syntax is similar to that of ‘C’ or Pascal language.
    So the language is very logical and well organized general-purpose programming language. Even people with a normal programming background can easily understand and capture the use of language. PHP is very advantageous for new users as its a very reliable, fluent, organized, clean, demandable and efficient.The main strength of PHP is the availability of rich pre-defined functions. The core distribution helps the developers implement dynamic websites very easily with secured data. PHP applications are very easy to optimize.
  • Loosely typed language: PHP encourages the use of variables without declaring its data types. So this is taken care at the execution time depending on the value assigned to the variable. Even the variable name can be changed dynamically.
  • Flexibility: PHP is known for its flexibility and embedded nature as it can be well integrated with HTMLXMLJavascript and many more. PHP can run on multiple operating systems like WindowsUnixMac OSLinuxetc. The PHP scripts can easily run on any device like laptops, mobiles, tablets, and computer. It is very comfortably integrated with various Databases. Desktop applications are created using advanced PHP features. The executable PHP can also be run on command-line as well as directly on the machine. Heavyweight applications can be created without a server or browser.
    It also acts as an excellent interface with relational databases.
  • Open Source: All PHP frameworks are open sources, No payment is required for the users and its completely free. User can just download PHP and start using for their applications or projects. Even in companies, the total cost is reduced for software development providing more
    reliability and flexibility.It supports a popular range of databases like MySQL, SQLite, Oracle, Sybase, Informix, and PostgreSQL.
    PHP provides libraries to access these databases to interact with web servers. Developers are free to post errors, inspect codes and can contribute to code as well as bug fixing. Many frameworks like Codeignitor, Zend Framework, CakePHP make use of PHP.Even many popular content management systems like WordPress, Joomla and Drupal use PHP as prime language.
    Because of the above reasons many web hosting companies and Internet Service providers prefers PHP.
  • Cross-platform compatibility: PHP is multi-platform and known for its portability as it can run on any operating System and windows environments. The most common are XAMPP (WindowsApache ServerMySQLPerl, and PHP) and LAMP (LinuxApacheMySQLPHP). As PHP is platform-independent, it’s very easy to integrate with various databases and other technologies without re-implementation. It effectively saves a lot of energy, time and money.
  • Error reporting and exceptions: PHP supports much errors reporting constants to generate errors and relevant warnings at run time. For example E_ERROR, E_WARNING, E_PARSE, E_STRICT.
    PHP5 supports exception handling which is used to throw errors which can be caught at any time.
  • Active community support: PHP is very rich with many diverse online community developers to help beginners for web-based applications. These worldwide volunteers contribute many features as well as new versions for PHP libraries. Even they contribute a translation in different languages to help out programmers. There is a bundle of third-party open-source libraries which provide basic functionalities. Even the documentation given by the official site helps in implementing new features providing access to a variety of creative imagination.
  • Fast and efficient performance: Users generally prefer fast loading websites.
    For any web development, speed becomes an important aspect which is taken care of by PHP.PHP scripts are faster than other scripting languages like ASP.NETPERL, and JSP. The memory manager of PHP 7 is very optimized and fast as compared to older versions of PHP. Even connecting to the database and loading of required data from tables, are faster than other programming languages. It provides a built-in module for easy and efficient database management system. The high speed of PHP is advantageous for users for its server administration and mail functionality. Also, it supports session management and removing of unwanted memory allocation.
  • Maintenance: When dealing with big projects, maintenance of code is also an important aspect of the web development process. There are many PHP frameworks for example MVC (Model View Controller) which makes development and maintenance of code easier. Files belonging to the different module are maintained separately.
  • Third-party application support and security: Many PHP’s predefined functions support data encryption options keeping it more secure. Even the users can use third-party applications to secure data.
  • Real time access monitoring: PHP also provides a summary of user’s recent logging accesses.
  • Memory and CPU usage information: PHP can provide memory usage information from functions like memory_get_usage() or memory_get_peak_usage(), which can help the developers optimize their code. In the similar way, the CPU power consumed by any script can be retrieved for further optimization.
  • Object oriented features: PHP supports object-oriented programming features, resulting in increased speed and introducing added features like data encapsulation and inheritance at many levels.
  • Magic Constants: PHP provides many built-in magic methods starting with __(double underscore) which are called during specific events.For example directory path(__DIR__), class name (__CLASS__), namespace (__NAMESPACE__), function name (__FUNCTION__), method name (__METHOD__), line number (__LINE__), file path (__FILE__).
  • Regular expression: PHP provides regular expression functions with parsing and pattern matching methods.
  • PDO Class: PHP Data Objects are created by PDO class which gives a good abstraction layer for database drivers. The PDO Classes are enriched with functions which are database independent. It means the same functions are used for similar actions for different databases without re-development as long as it supports PDO. In this way, the application becomes more portable saving lot of time and effort. Use of PDO helps the application from SQL injection attacks.

Additional Features:
The feature list is endless. The other features of PHP are manipulation of images using GD library, make remote connections using cURL, handling file system, managing user sessions, track sessions, Use of SimpleXML Class which reads and write XML files through objects, support of cookies and sessions, shell command-line execution, compression of ZIP archives, use of Ajax.

Major Features of PHP

  • HTTP authentication with PHP
  • Cookies
  • Sessions
  • Dealing with XForms
  • Handling file uploads
    • POST method uploads
    • Error Messages Explained
    • Common Pitfalls
    • Uploading multiple files
    • PUT method support
  • Using remote files
  • Connection handling
  • Persistent Database Connections
  • Safe Mode
    • Security and Safe Mode
    • Functions restricted/disabled by safe mode
  • Command line usage — Using PHP from the command line
    • Introduction
    • Differences to other SAPIs
    • Options — Command line options
    • Usage — Executing PHP files
    • I/O streams — Input/output streams
    • Interactive shell
    • Built-in web server
    • INI settings
  • Garbage Collection
    • Reference Counting Basics
    • Collecting Cycles
    • Performance Considerations
  • DTrace Dynamic Tracing
    • Introduction to PHP and DTrace
    • Using PHP and DTrace
    • Using SystemTap with PHP DTrace Static Probes

AWS

Installation Instructions for Windows

A) Choose Start, expand All Programs, and then select PHP

B) RDP Connection: To connect to the operating system,

1) Connect to virtual machine using following RDP credentials :

  • Hostname: PublicDNS  / IP of machine
  • Port : 3389

Username: To connect to the operating system, use RDP and the username is Administrator.
Password : Please Click here  to know how to  get password .

C) Other Information:

1.Default installation path: will be on your root folder “C:\inetpub\wwwroot”
2.Default ports:

  • Windows Machines:  RDP Port – 3389
  • Http: 80
  • Https: 443

Configure custom inbound and outbound rules using this link

AWS Step by Step Screenshots


Videos

How to install and configure php on iis 2008 R2

How to install and configure PHP Website on IIS 8 in Windows 2012

PHP on cloud

Related Posts