PHP Programming Languages

PHP was designed in 1995 by Rasmus Lerdorf because it needs a free tools to program Web pages and released under the name PHP/FI, (Personal Home Pages / Form Interpreter),.
He has developped it further with the help of other programmers and made it open source for the community of users. A new engine was created for PHP 3 and a new name given: PHP Hypertext Preprocessor in 1997. The Zend engine was created in 1999 for PHP 4.
PHP 5 was released in 2004, it is more object-oriented and supports XML.
A PHP script produces web pages, and may be embedded inside HTML code as JavaScript but works server side. It is similar to C, but dynamic variables and more prototype based. A server must be configured to execute the interpreter on pages with .php extensions, and to send resulting modified HTML pages on the network.
PHP is the P of LAMP, a popular architecture that includes the Linux operating system, the Apache server and the MySQL database manager.
A project to port PHP to .NET exists and is named Phalanger.


- All those of C, but typed variables, plus:
- Object oriented.
- Dynamic untyped variables prefixed by $.
- Associatives arrays (tables with keys).
- A foreach construct to scan arrays and iterators.
- Lot of APIs dedicated to the standard of the web and databases.

The language


The langage is not case-sensitive.
Floating point numbers are denoted by a dot followed by a number or zéro.
Variables are prefixed with a $ symbol and no type is specified in advance.
Literal string which use the "" notation are evaluated for variables and numbers.
Some symbols:

must enclose a PHP program.
# or // starts a comment.
array( "1" =>" "a, ...) is a dictionary.

Control structures

The if structure has elsif and else options.

if(x < 10)
   echo "$x less than 10\n";
   echo 'etc...\n'
The while structure:


Function or method

The definition starts with the function keyword, followed by the name and the list or arguments separated by commas, and the body is enclosed between { and }. 
The return keyword in the body of the definition allows to return one value.
function funcname( arguments )


class name


The body is similar to the global code.

Why use PHP?

PHP is an Internet tool, running server side, it is a scripting language that may be embedded into web pages. It is usable for processing large data and build a HTML page that display the results. (JavaScript is convenient for dynamic change of HTML pages.)
PHP 5 is a simpler concurrent to Java as an application server and a platform for web applications and web services. It eases the use of XML, MySQL, SQLite, SOAP and many database systems.
PHP is the most used language to build a CMS, content management system.

See also

  • PHP 6. Differences with the versions 4 and 5.
PHP 6 with Unicode support is abandoned.PHP Editors

Includes a PHP editor. (Windows)Extension to Eclipse for a PHP development interface.IDE from Sun written in Java for PHP and other languages.Online editor.

Development tools

The official website, home of the interpreter and the language.
Windows Apache Linux PHP local server. Put your PHP script in the www sub-directory at root of the Wamp directory and they can run as on a true server, with MySQL requests and PhpMyAdmin or SQLite Manager to manage the databases!
Extension to build graphical user interfaces for Windows. Demo.

Scripts and tutorials

Learn with examples to make PHP scripts for using SQL on a website.
Directories of sites and scripts (mainly HotScript, Scriptsearch, NeedScript et Scripts).
Sample code

Displaying chars of a string.
$str = "demo";
$len = strlen($str);
for($i = 0; $i < $len; $i++) 
  echo $str[$i];
Displaying elements of a list.
$arr = array(1,2,3 );
$arr = array_merge($arr, array( 4,5));
$sub = array_slice(|$arr, 1,3);
foreach($sub $as $num) 
  echo $num;
>> should display:  234

Related Posts Plugin for WordPress, Blogger...
Design by Kholid Al Fakhry | Bloggerized by Lasantha - Premium Blogger Themes | Kholid Al Fakhry