Skip to content

Latest commit

 

History

History
65 lines (36 loc) · 5.24 KB

File metadata and controls

65 lines (36 loc) · 5.24 KB

What is PHP

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language. PHP is a very popular scripting language for web development

It is a powerful language because with it you can use different programming paradigms such as OOP, procedural, functional. It has a robust support for OOP (has interfaces, abstract classes, etc..) and has several powerful features like traits, closures, generators. It seems that it combines differents features found in languages like Java, Javascript, C, python..

The best things in using PHP are that it is extremely simple for a newcomer, but offers many advanced features for a professional programmer. Although PHP's development is focused on server-side scripting, you can do much more with it.

PHP syntax is similar to Perl and C.

It is free and open-source Additionally:

  • PHP is a relatively easy language to learn. Programmers with backgrounds in languages such as C or Perl should have little problem learning PHP. There are also a large number of free online resources available.
  • PHP is a secure and stable scripting language. The open-source community is constantly improving PHP, as well as patching and fixing any bugs that are found.
  • PHP loads and runs quickly without slowing down other processes. This is because PHP runs in its own memory space.
  • PHP web hosting is cost-effective. Because PHP is open-source, there are no licensing fees associated with it.

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.


What PHP can do

Anything. PHP is mainly focused on server-side scripting, so you can do anything any other CGI program can do, such as collect form data, generate dynamic page content, or send and receive cookies.

There are three main areas where PHP scripts are used.

💡 Server-side scripting.

This is the most traditional and main target field for PHP. You need three things to make this work: the PHP parser (CGI or server module), a web server and a web browser. You need to run the web server, with a connected PHP installation. You can access the PHP program output with a web browser, viewing the PHP page through the server.PHP code may be embedded into HTML code, 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 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.

In terms of server-side programming languages, it is by far the most widely used, powering more than 80% of today’s websites

💡 Command line scripting.

You can make a PHP script to run it without any server or browser. You only need the PHP parser to use it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows).

💡 Writing desktop applications.

PHP is probably not the very best language to create a desktop application with a graphical user interface, but if you know PHP very well, and would like to use some advanced PHP features in your client-side applications you can also use PHP-GTK to write such programs.

With PHP you are not limited to output HTML. PHP's abilities includes outputting images, PDF files and even Flash movies (using libswf and Ming) generated on the fly. You can also output easily any text, such as XHTML and any other XML file. PHP can autogenerate these files, and save them in the file system, instead of printing it out, forming a server-side cache for your dynamic content. One of the strongest and most significant features in PHP is its support for a wide range of databases. Writing a database-enabled web page is incredibly simple using one of the database specific extensions (e.g., for mysql), or using an abstraction layer like PDO, or connect to any database supporting the Open Database Connection standard via the ODBC extension. Other databases may utilize cURL or sockets, like CouchDB.

PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP, COM (on Windows) and countless others. You can also open raw network sockets and interact using any other protocol. PHP has support for the WDDX complex data exchange between virtually all Web programming languages. Talking about interconnection, PHP has support for instantiation of Java objects and using them transparently as PHP objects.

PHP has useful text processing features, which includes the Perl compatible regular expressions (PCRE), and many extensions and tools to parse and access XML documents.


Links to resources