PHP is a server-side scripting language designed primarily for web development but also used a general purpose programming language. Originally created by Rasmus Lerdorf in 1994, the PHP reference implementation is now produced by the PHP Development Team. PHP originally stood for personal home page, but it now stands for the recrsive acronym PHP : Hypertext Preprocessor.
PHP code may be embedded into HTML or HTML5 markup, or it can be used in combination with various web template systems, web content management systems and web frameworks. PHP code is usually processed by a PHP interpreter implemented as a module in the web server or a Common Gateway Interface executable. The web server software combines the result 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 application.
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 envolved without a written formal spesification or standard until 2014, leaving the canonical PHP interpreter as a de facto standard. Since 2014work has gone on to create a formal PHP spesification.
Example #1 An Introductory example
<!DOCTYPE html>
<html>
<head>
<title> PHP #1</title>
</head>
<body>
<?php
echo" Hai Bro!!! Saya PHP... ";
?>
</body>
</html>
Instead of lots of commands to outpun HTML (as seen in C or Perl), PHP pages contain HTML with embedded code that does "something" (in this case, output "Hai Bro!!! Saya PHP..."). The PHP code is enclosed in special start and end processing intructions <?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 teh server, generating HTML which is then sent to the client. The client would receive the result of running that scripyt, but would not know what the underlying code was. We can even configure our web servers to process all our HTML files with PHP, and then there's really no way that users can tell what we have up our sleeve.
The best thing using PHP are that it extremelu simple for a newcomer, but offers many advanced features for a profesional programmer. Don't be affraid reading the long list of PHP's features. We can jump in, in a short time, and start writing simple scripts in a few hours.
Why Use PHP ?
We have obviously head of a number of programming languages out there, we may be wondering why we would want to use PHP as our passion 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 language 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 we 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 enaugh.
- PHP has in built support for working hand in hand with MySQL, this does not mean we can't use PHP with other database management systems. You can still use PHP with Postgree, Oracle, Ms. SQL Server, ODBC etc.
- PHP is cross platform, this means we can deploy our application on a number of different operating systems such as Windows, Linux, Mac and etc.
PHP stores integers in a platform-dependent range, either a 64 or 32 bit signed integer equivalent to the C-language long type. Unsigned integers are converted to signed values in certain situations, this behavior is different from that of other programming languages. Integer variables can assigned using decimal, octal, hexadecimal and binary notations.
Floating point numbers are also stores in a platform specific range. They can be specified using floating point notation or two forms of scientific notation. PHP has a native boolean type that is similiar to the native boolean types in Java and C++. Using the boolean type conversion rules, non-zero values are intrepeted as true and zero as false, as in Perl and C++. The null data type represent a variable that has no value, NULL is only allowed value for this data type.
Is PHP Support Object Oriented Programming ?
Basic OOP functionality was added in PHP 3 and improved in PHP 4. This allowed for PHP to gain futher abstraction, making creative task, easier for programmers using the language. Object handling was completely rewritten for PHP 5, expanding the feature set and enhancing performance. In previous versions of PHP, objects were handled like value types. The drawback of this method was that code had to make heavy use PHP's reference variables if it wanted to modify an object it was passed rather than creating a copy of it. In the new approach, objects are referenced by handled, and not by value.
PHP 5 introduced private and protected membber variables and methods, along with abstract classes, final classes, abstrac methods, and final methods. It also introduces a standard way of declaring contructors and destructors, similiar to thatt of other OOP language such as C++ and a standard exception handling model. Furthermore, PHP 5 added interfaces and allowed for multiple interfaces to be implemented. There are special interfaces that allow objects to interac with the runtime system. Objects implementing ArrayAcces can be used with array syntax and objecs implementing iterrator or iteratorAgregate can be used with the foreach language construct. There is no virtual table feature in the engine, so static variables are bound with a name instead of a reference at compile time.
Tags:
PHP