Basics of PHP
PHP (PHP Hypertext Preprocessor) is an open source general HTML embedded purpose scripting language which is specially used for web development. 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.
PHP Scripts can be used mainly for three purposes :
Server-Side Scripting : Three things are required 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.
Command Line Scripting : PHP script can be run 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 Unix or Linux) or Task Scheduler (on Windows). These scripts can also be used for simple text processing tasks.
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.
PHP Versions :
- PHP was created sometime in 1994 by Rasmus Lerdorf. Rasmus Lerdorf, who wrote the original Common Gateway Interface (CGI) component, together with Andi Gutmans and Zeev Suraski, who rewrote the parser that formed PHP 3. PHP takes most of its syntax from C, Java, and Perl. PHP was written in the C programming language by Rasmus Lerdorf in 1994 for use in monitoring his online resume and related personal information.
- The Second generation implementation started to evolve PHP from a suit of tools into a programming language. It included built in support for DBM, mSQL, Postgres95 database, cookies, user-defined function support and much more. Lerdorf combined PHP with his own Form Interpreter, releasing the combination publicly as PHP/FI (generally referred to as PHP 2.0) on June 8, 1995.
- One of the biggest strengths of PHP 3.0 are the user interface for the multiple databases, protocols and APIs, the ease of extending the language itself attracted dozens of developers who submitted a variety of modules. Other key features introduced in PHP 3.0 included object-oriented programming support and a far more powerful and consistent language syntax. In June, 1998, with many new developers from around the world joining the effort, PHP 3.0 was announced by the new PHP Development Team as the official successor to PHP/FI 2.0.
- By 1998, shortly after PHP 3.0 was officially released, Andi Gutmans and Zeev Suraski had begun working on a rewrite of PHP's core. The design goals were to improve performance of complex applications, and improve the modularity of PHP's code base. The new engine, dubbed 'Zend Engine' (comprised of their first names, Zeev and Andi), met these design goals successfully, and was first introduced in mid 1999. PHP 4.0, based on this engine, and coupled with a wide range of additional new features, was officially released in May 2000. PHP 4.0 included other key features such as support for many more web servers, HTTP sessions, output buffering, more secure ways of handling user input and several new language constructs.
- PHP 5 was released in July 2004 after long development and several pre-releases. It is mainly driven by its core, the Zend Engine 2.0 with a new object model and dozens of other new features. PHP's development team includes supporting projects, such as PEAR, PECL, and documentation, and an underlying network infrastructure of well over one-hundred individual web servers on six of the seven continents of the world.
Advantages of PHP:
- Open source: It is developed and maintained by a large group of PHP developers, this will helps in creating a support community, abundant extension library.
- Speed: It is relative fast since it uses much system resource.
- Easy to use: It uses C like syntax, so for those who are familiar with C, it's very easy for them to pick up and it is very easy to create website scripts.
- Stable: Since it is maintained by many developers, so when bugs are found, it can be quickly fixed.
- Powerful library support: You can easily find functional modules you need such as PDF, Graph etc.
- Built-in database connection modules: You can connect to database easily using PHP, since many websites are data/content driven, so we will use database frequently, this will largely reduce the development time of web apps.
- Can be run on many platforms, including Windows, Linux and Mac, it's easy for users to find hosting service providers.
Disadvantages of PHP :
- Security : Since it is open sourced, all people can see the source code as text in public folder if any thing mishappen in apache. PHP does not it self protect its file. If there are bugs in the source code, it can be used by people to explore the weakness of PHP
- Not suitable for large applications: Hard to maintain since it is not very modular. Now a days, lots of framework and CMS has arrived in market to sort this problem.
- Weak type: Implicit conversion may surprise unwary programmers and lead to unexpected bugs. For example, the strings "1000" and "1e3" compare equal because they are implicitly cast to floating point numbers.