[PHP] Fundamentals of PHP Technology

Source: Internet
Author: User
Tags php language php server drupal
Origin

I have been using the PHP language for many years. In the past few years, although did not use PHP to develop what big project, but has been using PHP to do some small stuff, and focus on the development of PHP. Why is the PHP language so interesting to me? There are two reasons:

PHP is an open source language, and its languages and libraries are open source. And it has a mature open source community, which is a great support for technology developers; PHP is a fully web-oriented language. The focus of PHP on Web development makes the language more advantageous than other languages in web development. PHP, for example, can write both a plume-level Web site and a large-scale Web application that supports hyper-load. PHP has many clear and concise solutions on the web that cannot be compared with many common languages. For example, another open-source language I like Python, which can also be used to develop Web applications. But Python's goal is clearly not limited to web development, so Python's productivity is no better than PHP for Web development.

While all of these are personal points of view, from a practical standpoint, PHP is clearly the most popular language in Web applications. Many well-known websites are built on PHP.

The web development that I experienced in previous years is still focused on. NET platform. So for PHP, just as a personal treasure, and not many actual project application. But from this year onwards, with the development of software open source trend, the use of PHP on the web side of the project is also more up. Several of my friends are developing PHP projects that were difficult to see a few years ago. I am glad to see this change. Open source development is bound to profoundly affect the development of software industry, so that more and more rich software resources will be produced, we will face is no longer the "Wintel" world, which is very good ...

So I've compiled some of these PHP technical notes over the years as a pillar on my own web development. Before this stone is a bit of fragmented PHP enthusiasts, after this stone I will be more in-depth exploration of PHP technology, in the PHP world deep plowing.

PHP Basic Grammar Impressions

PHP is an application-oriented language. It draws inspiration from multiple languages and contains many linguistic traits. Therefore, for those familiar with C, C + +, Java and other languages, the PHP language is very studious. And it uses one of the most direct embedding methods?? 。 This embedding minimizes its contact with HTML and XHTML, which is extremely economical from an engineering standpoint. Because of this, when PHP appears, MS can introduce this approach to IIS and develop an ASP language.

Of course, the direct embedding of the way there are many problems, its most important is not bigger. A little homepage is possible, but a multi-person team-operated Web application is difficult. PHP draws on the include method from C + +, and makes multi-document association based on keywords such as include, require, require_once and so on. In PHP4/5, we emphasize the separation between the front and rear stations, and use MVC design pattern to build the Web program. After years of development, the PHP language is capable of developing large web applications.

I think the core of the PHP language should be:

Libraries and frameworks: referencing the experience in C + +, library learning is the core of PHP. There are two types of libraries in PHP?? Core libraries (cores) and expansion libraries (Extend). The core library should be dedicated to string manipulation, array manipulation, date manipulation, and regular expression operations, many of which are web-based UIs, and Web program input and output is a critical technology that involves many security and stability issues, as well as user experience issues. And the expansion of the library is easy to develop. PHP has a wealth of expansion library resources, whether it is pecl expansion or pear expansion, or sf.net on the many PHP program modules, can be mined for reference. And some mature libraries or programs have become a stable framework, such as Smarty and Drupal. Using these frameworks can greatly improve the speed and quality of project development, and reading these frameworks can greatly improve the ability of self-PHP. It is most worthwhile to spend time and effort on libraries and frameworks. OOP development and Design patterns: Although OOP is not supported until PHP5, it is possible to emulate a class's dynamics model in PHP4 using "Callback Functions" (callback function). And now OOP has become the basic technology, whether it is a large-scale project program for many people, or a single-person small program, should be used in the way of OOP. PHP's simplest callback function is a function variable, like the following.
   
Quick Overview of PHP technology

I've compiled some of the PHP technologies I've accumulated over the years, mainly in the following categories:

String library: In Java,. NET has similar string processing function library, need to pay attention to the Unicode character processing library mbstring expansion Library; array processing: Unlike C/s + +, the PHP array processing technique is very complex and closely related to page efficiency. For example, to use Shuffle () or array_rand () to randomly extract elements, try to use foreach instead of using for to iterate through the array. More importantly, the PHP array assumes the role of the configuration object and the storage object, before the use of many libraries or frameworks to set up a configuration array for custom configuration; date and time: You need to be aware of where it applies, and it does not necessarily detail its data at the millisecond level, and its efficiency is likely to be related to the server and network environment. Therefore, for PHP program testing, the client's JavaScript should be used for timing, and the PHP server side of the timing of the comparison will be more useful; regular expressions and server variables: in PHP, regular expressions and server variables are used to prevent attacks, The most basic tool for filtering and verifying HTTP access. My approach is to develop a Myfilter class based on regular expressions and server variables, which is used to filter information for the most basic protection. Database: In-depth study of data abstraction layer technology, for METABASE/PEAR:DB/PDO and ADODB and other abstract layer library have a good understanding. In this way the database program can have a good ability to transplant. I choose ADODB, the main reason is its with. NET architecture is similar and can support Python. Session Management: In the WEB2 environment, the management of cookies is more important than the session. The core business steps in the PHP project are not AJAX-based, session-based management, and for other non-core businesses (primarily queries), cookies can be used to send part of the JavaScript program to cookies, which is a great way to improve the customer experience. Internationalization and Localization: PHP projects should adhere to UTF-8 encoding (page and data), and in the programming UI, you should use the GetText Extension library for multi-language support. My approach is to develop PHP based on the Drupal framework, leveraging the T-function provided by Drupal for internationalization and localization. Cache and encryption: PHP has a good cache technology and encryption technology, the relevant library has Ob_ library, MD5, SHA1, Cracklib expansion Library and Mycrypt expansion library. The use of caching and encryption technology can effectively improve the performance of the system, especially in the core data processing. For the user experience, I focus on the use of AJAX technology and XML combination, other technologies: PHP Shell Technology can achieve some of the system's business automation, and the use of CURL Library can make some automatic crawler, for unit test and data mining work; PHP has a good technical solution for image processing, GD2, Ming and ImageMagick are good choices.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.