LT   EN   RU  
2021 г. январь 17 д., Straipsniai.lt - Информационный портал
  
  Компьютеры > Компьютерные технологии > Программирование
Lankomumo reitingas Версия для печати Версия для печати
Why PHP?
 According to NetCraft surveys, PHP is now the most popular module for the Apache server and in total running on something like two million Web sites. Here are some of the reasons why PHP is such a popular server side scripting language.

A short history

PHP (which originally stood for Personal Home Page) was first written by Rasmus Lerdorf as a simple set of Perl scripts to track users of his Web pages. He soon had enquiries from other people and rewrote it as a scripting engine. He also added support for forms, thus forming PHP/FI. As its popularity grew, a core group of developers created an API for it and turned it into PHP3. By now PHP was being used in situations which were never envisaged, and so a complete rewrite of the script parser was undertaken (the Zend engine), creating PHP4, which was much faster than PHP3. PHP now stood for PHP Hypertext Processor, and was ready for the big time...

What to look for in a scripting engine.

The Four S's: Speed, Stability, Security and Simplicity.

  • Speed -- not only the speed of execution, which is important, but also that it not slow down the rest of the machine. So it should not demand a lot of system resources. PHP integrates well with other software, especially under UNIX's, has a small footprint and when run as an Apache module is already loaded for use. Plus, PHP is a thin wrapper around many operating system calls, so can be very fast.
  • Stability -- its no good being fast if the system crashes every few thousand pages. No application is bug free, but having a community of PHP developers and users makes it much harder for bugs to survive for long. Under the hood, PHP uses its own resource management system, and has a sophisticated method for handling variables, making it intrinsically a robust system.
  • Security -- the system should be protected from malicious attacks from users, both as programmers and as surfers. PHP provides many levels of security which can be set in the .ini file to the desired level.
  • Simplicity -- programmers should be able to start being productive as soon as possible. With PHP, even HTML coders can start integrating PHP into their pages straight away. Programmers with previous experience of C, or even with Javascript can get up to speed very quickly.

Oh, and Connectability (which doesn't start with an 'S'). Because of PHP's modular system of extensions it will interface with many diverse libraries, and adding further extensions is very simple. This allows PHP to make use of specialised working libraries from many different areas, such as encryption, graphics, XML and so on.

Further advantages of PHP.
  • PHP will run on (almost) any platform. Using the same code base, PHP can be compiled and built on about 25 platforms, including most UNIXs, Windows(95/98/NT/2000) and Macs. As this uses the same code base, all scripts will run identically, whatever the platform.
  • PHP is similar to C. So anyone who has experience with a C-style language will soon understand PHP. In C-style languages we can also include Javascript and Java. In fact, much of PHP's functionality is provided by wrappers around the underlying system calls (such as fread() and strlen()) so C programmers will immediately feel at home.
  • PHP is extendible. PHP consists of the core parsing engine (written by Zend), a set of core code modules and then a set of code extensions. This allows programmers two ways of extending PHP to do some special processing, either by writing an extension module and compiling it into the executable, or by creating an executable that can be loaded using PHP's dynamic loading mechanism.
  • Lots of HTTP server interfaces. PHP currently will load into Apache, IIS, AOLServer, Roxen and THTTPD. Alternatively, it can be run as a CGI module.
  • Lots of database interfaces. PHP currently will work with MySQL, MS SQL, Oracle, Informix, PostgreSQL and many others. These are binary level interfaces, and ODBC is also provided for those situations where the database is not supported.
  • And lots of other modules... when a PHP user wants to interface to particular library, then it is easy to write an interface for it, and many have done so, and contributed to the main PHP source repository. So you can find modules for graphics routines, PDF files, Flash movies, Cybercash, calendars, XML, IMAP, POP and a host of others. If the library you need is not supported, you can either write one yourself, or employ your favourite programmer to do it.
  • PEAR. The PHP Extension and Add-on Repository. Similar to the CPAN network for Perl, although still in its infancy, the idea of PEAR is to provide a set of PHP scripts that would be installed by default with the PHP installation
  • Fast. PHP is normally used an Apache module and this makes it very fast. It is entirely written in C and is quite small, so loads and executes quickly with small memory footprint.
  • PHP is Open Source. Almost a religious matter to some people! In purely practical terms, it means that you are not dependent on a manufacturer to fix things that don't work, nor are you forced to pay for upgrades every year to get a working version. Those of us who have waited for Allaire to get something fixed will appreciate this.
On the down side

Error handling is not as sophisticated as Cold Fusion or ASP.

There is no IDE or debugger. An IDE is probably not important for most people and a debugger is promised from Zend Tech. in the very near future. Most people continue using the same environment they use for HTML development.

When should you use PHP, and when should you use another scripting language?

If you are running on a UNIX or Linux platform, you have the choice between Perl and PHP, both excellent for scripting. Where PHP has the edge is in being much simpler for people new to writing scripts, making it more productive in the earlier stages. Perl also relies on having the correct modules downloaded from CPAN for some of the more off-beat functionality, whereas they come as part of the PHP distribution. Of course, there's no reason not have both Perl and PHP!

On a Windows platform, there is competition from ASP and Cold Fusion. Here the choice can be as much political as technical, and ASP with IIS is probably a safer bet than PHP with IIS. But on a purely technical basis, PHP is as stable on WindowsNT as either of the other two, at least as fast and less resource intensive. However, ASP offers far better integration into the underlying operating system and databases, especially if you want to make use of COM.

Conclusion

Like so many things in the programmers tool kit, PHP has developed almost accidentally. What started as one person's experiment with scripting, managed to fulfil a need for many other programmers, a need for a small, fast and simple scripting language that could work seamlessly with many other components. In the last three years PHP has grown to become a major player in the server side scripting market.

Recently, another acronym was coined, LAMP, standing for Linux, Apache, MySQL, PHP - now considered an important package in the Internet world, a set of programs that work together to produce dynamic, data-driven Web sites.

A list of high profile sites can be found at www.php.net/sites.php, among them are sites that cover the whole range of the Net, from computer magazines to government, finance to games.

Resources

www.php.net - PHP.net, the central PHP site.
www.zend.com - Zend, home of the PHP parsing engine. Plus many interesting tutorials and articles.
www.phpbuilder.com - PHPBuilder, a PHP resource, with articles and tutorials.
http://px.sklar.com/ - the PHP code exchange containing snippets of PHP code.

         

Lankomumo reitingas

Oбсудить на форуме - Oбсудить на форуме

Версия для печати - Версия для печати

Назад
Случайные теги:    Египет (5)    Книги (2)    Кошки (11)    НЛП (18)    Психиатрия (13)    Спорт (40)    Собаки (6)    Поэты (3)    Право человека (8)    Аквариумы (10)    Кормление (4)    Гостья из будущего (35)    Кулинария (39)    Путешествия (2)    Помощ и превенция (2)    Генетика (10)    Linux/Unix (5)    Психология (27)    Архитектура (3)    Операционные системы (8)    Сертификаты SSL (10)    Процессоры (7)    Хакеры (116)    Хоби (27)    Образование (101)    Археология (3)    Лов рыбы (11)    Безопасность (43)    Технологий (4)    Физкультура (3)    Люди (94)    НЛО (24)    Стиль (5)    Вирусы (25)    Йога (9)    Набоков В. В. (94)    Медицина (84)    Военное искусство (3)    Педагогика (10)    Экология (18)    Общение (322)    Язычество (3)    Астрология (13)    Татуировки (5)    Бизнес и финансы (20)    Фото (11)    Английский язык (2)    Здоровье (86)    Туризм (25)    Боевые искусства (10)
1. JavaScript
1. JavaScript
Map