Whenever anyone is learning PHP, the most common questions that first come up are: What is PHP? And how does it work?
It is precisely these questions we will look at in this lesson. It’s a big help to understand such basics related to PHP before you start developing you own PHP pages. Such basic understanding will increase the speed of learning significantly.
What is PHP?
PHP stands for PHP: Hypertext Preprocessor
PHP is a widely-used, open source scripting language
PHP scripts are executed on the server
PHP is free to download and use
PHP was originally an acronym for Personal Home Pages, but is now a recursive acronym for PHP: Hypertext Preprocessor.
PHP was originally developed by the Danish Greenlander Rasmus Lerdorf, and was subsequently developed as open source. PHP is not a proper web standard – but an open-source technology. PHP is neither real programming language – but PHP lets you use so-called scripting in your documents.
To describe what a PHP page is, you could say that it is a file with the extension . php that contains a combination of HTML tags and scripts that run on a web server.
What is a PHP File?
PHP code are executed on the server, and the result is returned to the browser as plain HTML
PHP files have a default file extension of “.php”
What Can PHP Do?
PHP can generate dynamic page content
PHP can create, open, read, write, and close files on the server
PHP can collect form data
PHP can send and receive cookies
PHP can add, delete, modify data in your database
PHP can restrict users to access some pages on your website
PHP can encrypt data
With PHP you are not limited to output HTML. You can output images, PDF files, and even Flash movies. You can also output any text, such as XHTML and XML.
Unique Features of PHP
Loosely Typed Language – PHP supports variable usage without declaring its data type. It will be taken at the time of the execution based on the type of data it has on its value.
Cross Platform Compatibility – It is used to create the desktop application by using advanced PHP features.
Variable variables – PHP allows changing the variable name dynamically by using variable variables.
Real-Time Access Monitoring – PHP provides access logging by creating the summary of recent accesses for the user.
Magic Method – PHP has built in methods starts with __ (double underscore). These methods can’t be called directly. Rather, it will be called on the event basis. For example, __clone() will be called, when the clone keyword is used.
Error Reporting – It has some predefined error reporting constants to generate a warning or error notice. For example, when E_STRICT is enabled, a warning about deprecated methods will be generated.
Extended Regular Expression – PHP provides REGEX methods with extensive parsing and pattern matching mechanism with remarkable speed.
nowdocs and heredocs String – PHP provides the nowdocs and heredocs properties are used to delimit some block of context. nowdocs and heredocs are same except the context in the heredocs allow variable parsing.
Traits – PHP is a single inheritance language. The traits concept is used to cover inheritance limitation and support inheritance at multiple levels.
PHP runs on different platforms (Windows, Linux, Unix, Mac OS X, etc.)
PHP is compatible with almost all servers used today (Apache, IIS, etc.)
PHP has support for a wide range of databases
PHP is free. Download it from the official PHP resource: www.php.net
PHP is easy to learn and runs efficiently on the server side
How does PHP work?
The best way to explain how PHP works is by comparing it with standard HTML. Imagine you type the address of an HTML document (e.g. http://www.mysite.com/page.htm) in the address line of the browser. This way you request an HTML page.
No token or token has expired.