: Hà Nội) pronunciation (help·info), estimated population 3,058,000(2004), is the capital of Vietnam. From 1010 until 1802, it was the political center of an independent Vietnam with a few brief interruptions. It was eclipsed by Huế during the Nguyen Dynasty as the capital of Vietnam, but served as the capital of French Indochina from 1887 to 1945. From 1945 to 1976, it was the capital of North Vietnam.
The city is located on the right bank of the Red River. Hanoi is located at 21°2' North, 105°51' East (21.0333, 105.85), 1,760 km (1,094 mi) north of Ho Chi Minh City (formerly Saigon). [2]
History
Hoàn Kiếm Lake in the center of Hanoi, with the streets of the old town in the background (1999)
Hoàn Kiếm Lake in the center of Hanoi, with the streets of the old town in the background (1999)
The area around modern Hanoi has been inhabited for at least 3000 years BC. One of the first known permanent settlements is the Co Loa citadel founded around 200 BC.
Through history, Hanoi was known by many names. During Chinese domination of Vietnam, it was known as Long Bien, Tống Bình and later Long Đỗ. In 866, it was turned into a citadel and was named Đại La.
In 1010, Lý Thái Tổ, the first ruler of the Lý Dynasty (Triều Lý), moved the capital of Đại Việt (the Great Viet, then the name of Vietnam) to the site of the Đại La Citadel. Claiming to have seen a dragon ascending the Red River, he renamed it Thăng Long (Ascending dragon)—a name still used poetically to this day. It remained the capital of Vietnam until 1397, when the capital was moved to Thanh Hóa, also known as Tây Đô (Western Capital). Thăng Long then became Đông Đô (Eastern Capital).
In 1408, Vietnam was invaded by Chinese troops from the Ming Dynasty and Đông Đô was renamed Đông Quan (Eastern Gateway) by the Chinese. In 1428, Vietnam was liberated from Chinese rule by Lê Lợi, the founder of the Le Dynasty (Triều Lê ) and Dông Quan was renamed Đông Kinh (Eastern Capital—the name known to Europeans as Tonkin; and the same characters used for Tokyo). During the Tây Son Dynasty, it was named Bắc Thành (Northern Citadel).
In 1802, when the Nguyễn Dynasty (Triều Nguyễn) was established and then moved the capital down to present-day Huế, it was renamed Thăng Long. However, the second syllable of the toponym is actually a homonym of the word long, and so, actually suggests "to flourish" as opposed to "dragon". Therefore the name would be translated roughly to to ascend and flourish. In 1831 the Nguyen Dynasty renamed it Hà Nội (which can be translated as around the bend of the river or River Interior) . Hanoi was occupied by the French in 1873 and passed to them ten years later. It became the capital of French Indochina after 1887.
The city was occupied by the Japanese in 1940, and liberated in 1945, when it became the seat of Vietnam's government. From late 1946 to early 1947, it was the scene of heavy fighting between the French and Viet Minh forces. At that point, the city became the capital of an independent North Vietnam.
During the Vietnam War Hanoi's transportation facilities were disrupted by the bombing of bridges and railways, which were, however, promptly repaired. Following the end of the war, Hanoi became the capital of all Vietnam when North and South Vietnam were reunited on July 2, 1976.
In 2004, during site surveys for construction of a new parliament house, the remnant of a massive 900 years old citadel was discovered in central Hanoi, near the site of Ba Dinh square.
[edit] Geography
[edit] Districts
Hanoi comprises of eight inner districts of Ba Đình, Cầu Giấy, Đống Đa, Hoàn Kiếm, Hai Bà Trưng, Hoàng Mai, Long Biên, Tây Hồ and Thanh Xuân, and five outer districts of Đông Anh, Gia Lâm, Từ Liêm, Thanh Trì and Sóc Sơn.
[edit] Climate
Hanoi experiences the typical climate of northern Vietnam, where summers are hot and humid, and winters are relatively cool and dry. The summer months from May to September receive the majority of rainfall in the year (1,682 mm rainfall/ year). The winter months from November to March are relatively dry, although spring then often brings light rains. The minimum winter temperature in Hanoi can dip as low as 6–7°C (43°F), while summer can get as hot as 38–40 (100-104°F). Central heating is not common in Hanoi, and wind chills may make one feel rather cold in winter.[3]
[edit] Education
Hanoi, as the capital of Indochina, was home to the first western-style universities in Indochina, including: Hanoi Medical College (1902), Indochina University (1904), and École Supérieure des Beaux-Arts de L'Indochine (1925).
Hanoi is the largest center of education in Vietnam. Admissions to undergraduate study are through entrance examinations, which are conducted annually and open for everyone in the country. The majority of universities in Hanoi are public, although in recent years a few private universities have started their operation.
Because most of the national universities are located in Hanoi (and Ho Chi Minh City), students from other provinces wishing to enter university often travel to Hanoi for the annual entrance examination. Such events often take place in June/July, when a large number of students and their families converge on the city for a few weeks around the examimation period. In recent years, these entrant exams have been centrally set by the ministry of education, but the passmarks are decided independently by each university.
Pre-tertiary schools in Hanoi mainly serve their local districts. Education is equivalent to the K–12 system in the US, with elementary school between grades 1 and 5, middle school (or junior high) between grades 6 and 9, and high school from grades 10 to 12.
Some pre-tertiary schools might have a few selective classes for students with higher entry scores, with a stronger emphasis on subjects such as mathematics or sciences. In addition, some schools are designated as selective where admissions are also by entrant examination on the subjects of specialization. A few major universities in Hanoi also run a limited number of high-school and middle-school classes out of their Hanoi campuses for gifted students in subjects such as mathematics, chemistry, physics, information technology, linguistics, biology, and other social science and humanity subjects.
[edit] Places of interest
Ba Dinh square
Ba Dinh square
As the capital of Vietnam for almost a thousand years, Hanoi is considered to be the cultural center of Vietnam, where every dynasty has left behind their imprint. Even though some relics have not survived through wars and time, the city still has many interesting cultural and historic monuments for visitors and residents alike.
Hanoi opera house
Hanoi opera house
Some of the prominent places are: The Temple of Literature (Văn Miếu), site of the oldest university in Vietnam; One Pillar Pagoda (Chùa Một Cột); Flag Tower of Hanoi (Cột cờ Hà Nội); The Old Quarter and Hoàn Kiếm
Hanoi is also home to a number of museums, including the Vietnamese National History Museum, the National Museum of Ethnology, the National Museum of Fine Arts and the Revolution Museum .
The Temple of Literature , main entry
The Temple of Literature , main entry
The Old Quarter, near the scenic Hoan Kiem lake, has the original street layout and architecture of the old Hanoi. At the beginning of 20th century, the city consisted of only about 36 streets, most of which are now part of the old quarter. Each street then comprised of merchant and household specialized in a particular trade, such as silk traders, jewellery, etc. The street names nowadays still reflect these specializations, although few of them remain exclusively in their original commerce. The area is in general famous for its small artisans and merchants, including many silk shops. Local cuisine specialties as well as several clubs and bars can be found here also. A night market in the heart of the district opens for business every Friday, Saturday, and Sunday evening with a variety of clothing, souvenirs, and food.
West Lake (Hồ Tây) is a popular place for people to hang out. It is the largest lake in Hanoi, and there are many temples to visit in the area. There are small boats for hire, and a floating restaurant which has been operating for a couple of decades.
[edit] Population
Hanoi's population is constantly growing, a reflection of the fact that the city is both a major metropolitan area of Northern Vietnam, and also the country's political centre. This population growth also puts a lot of pressure onto the infrastructure, some of which is antiquated and dates back from the early 20th century.
When you talk to Hanoians, they will concede that most people you meet in Hanoi these days are from somewhere else. If you define a native Hanoian as someone who has been here for three generations or more, that number is likely to be very small as compared to the overall population of the city. Even in the Old Quarter, where commerce started hundreds years ago and was mostly a family business, many of the street-front stores nowadays are owned by merchants and retailers from other provinces. The original owner family may have either rented out the store and moved to live further inside the house, or just moved out of the neighbourhood altogether. The pace of change has especially escalated after the abandonment of central-planing economic policies, and the loosening of the district-based household registrar system.
The considerate and genteel nature of Hanoians is occasionally quoted in idioms and literature, which may appear as annoyingly snobbish. In reality, they are a reflection of a past where Hanoi is the convergent point for much of the country's talents in arts and education. They are also a reflection of a system heavily entrenched in Confucian values where modesty and consideration of others were regarded with a higher priority than one's self. As the opening up of the economy has brought in other pressures on people's daily life, advocates for traditional social and family values are in many ways helping to counter an "everyone for himself" mentality.
[edit] Transportation
Motor scooters dominate the roads in the Old Quarter
Motor scooters dominate the roads in the Old Quarter
Hanoi is served by Noi Bai International Airport, located in the Soc Son District, approximately 40 km (25 miles) north of Hanoi. Noi Bai is the only international airport for the northern regions of Vietnam. Direct daily flights are available to other cities in Vietnam, Asia, Australia, and Europe. Flights to and from the Americas usually involve a transit. The airport has recently been rebuilt with modern facilities.
There are two main highways linking the airport and city. The route to the city via Thang Long Bridge is more direct than Highway 1, which runs along the outskirts of the city. The main highways are shared by cars, motor scooters, with separate lanes by the side for bicycles. Taxis are plentiful and usually have trip meters, although it is also common to agree on the trip price before taking a taxi from airport to the city center. Tourists also sometimes tour the city on Cyclos especially in the Old Quarter.
Hanoi is also the origin departure point for many train routes in the country. The Union Express (tàu Thống Nhất) runs from Hanoi to Ho Chi Minh City from Hanoi station (formerly Hang Co station), with stops at cities and provinces along the line. Trains also depart Hanoi frequently for Hai Phong and other northern cities.
The main means of transport within the city are motobikes, buses, taxis, and bicycles. Motobikes remain the most common way to move around the city, due to their flexibility in navigating small streets, lack of parking spaces for cars, and also being more fuel economic than automobiles. The number of private cars are however rising every year, and traffic at peak hours can be very heavy at main intersections.
Public buses run on many routes and fare can be purchased on the bus. For short trips, "xe ôm" (literally, "hug vehicle") motorcycle taxis are available where the passenger sits at the rear of a motobike and the driver will take you to your destination. A taxi is more convenient for longer trips, and if you do not wish to travel in open air.
[edit] Economy
Though representing only 3.6 percent of the country's population and 0.3 percent of the national territory, Hanoi contributes 8 percent to the national GDP and 45 percent of the Red River Delta's economy.
Industrial production in the city has experienced a rapid boom since the 1990s, with average annual growth of 19.1 percent from 1991–95, 15.9 percent from 1996–2000, and 20.9 percent during 2001–2003. In addition to eight existing industrial parks, Hanoi is building five new large-scale industrial parks and 16 small- and medium-sized industrial clusters. The non-state economic sector is expanding fast, with more than 25,000 businesses currently operating under the Enterprise Law.
Trade is another strong sector of the city. In 2003, Hanoi had 2,000 businesses engaged in foreign trade, having established ties with 161 countries and territories. The city's export value grew by an average 11.6 percent each year from 1996–2000 and 9.1 percent during 2001–2003. The economic structure also underwent important shifts, with tourism, finance, and banking now playing an increasingly important role.
Agriculture, previously a pillar in Hanoi's economy, has striven to reform itself, introducing new high-yield plant varieties and livestock, and applying modern farming techniques.
Together with economic growth, Hanoi's appearance has also changed significantly, especially in recent years. Infrastructure is constantly being upgraded, with new roads and an improved public transportation system. The rate of telephone users was 30 per 100 people in 2003. New urban areas are growing rapidly, with 1.5 million square metres of housing constructed during 1996–2000 and 1.3 million square metres built in 2003 alone.
Social services have been developed in both scale and quality. The public healthcare network has been strengthened, ensuring at least one doctor for each commune and ward. Thanks to these accomplishments, Hanoi has the highest development index in the country. Movements such as raising donations for poor people or promoting a "cultural lifestyle", have received support from local people and been maintained.
[edit] Health care and other facilities
The following medical facilities are located in Hanoi:
* Bach Mai Hospital
* Viet Duc Hospital
* Saint Paul Hospital
* 108 Hospital
* L'Hôpital Français De Hanoï
* Hanoi Dental Clinic
* Hanoi Family Medical Practice
* International SOS Clinic
* 19-8 Hospital
[edit] Photos of Hanoi
The Temple of Literature, called ' la pagode des corbeaux " under the French
The Temple of Literature, second court yard
The Temple of Literature, steles with names of those successful at the imperial exams
The Temple of Literature, third court yard
The Temple of Literature, third court yard
The Temple of Literature, main hall
The Temple of Literature, main hall
The Temple of Literature
One Pillar Pagoda
Presidential Palace, Hanoi (formerly Place of The Governor-General of French Indochina)
Presidential Palace during APEC2006
Presidential Palace at night during APEC2006
Grand Opera House
State Guest House (formerly Residence of Resident - Superior of Tonkin)
Historic hotel Sofitel Metropole Hanoi
Flag Tower of Hanoi
Tran Quoc pagoda
The cathédrale St-Joseph
Statue of Ly Thai To, founder of Hanoi
Hoan Kiem lake
The Huc bridge and Hoan Kiem lake
The Old Quarter
Kham Thien street, old days
Phan Dinh Phung street, former boulevard Carnot
National Museum of Fine Art
National Museum of History
Hanoi tower (built on the land of the famous prison Hanoi Hilton)
Long Bien bridge
West Lake
Trang Tien street, former rue Paul-Bert
A busy street
Ho Chi Minh mausoleum
A new street
A new quarter
Park of Reunification (former Lenin park)
Selling flower in the street
A French colonial-style house
An old house (Pho Hang Hom)
Old street—A photo of a painting by Bui Xuan Phai—a famous Vietnamese painter
Saturday, January 13, 2007
PHP
PHP (PHP: Hypertext Preprocessor) is a reflective programming language originally designed for producing dynamic Web pages.[1] PHP is used mainly in server-side application software, but can be used from a command line interface or in standalone graphical applications.
PHP competes with other programming languages such as Perl, Ruby, and Python; as of December 2006, it is ranked 5th, down from 4th last year, by TIOBE Programming Community Index. The rankings are based on world wide availability of practitioners, courses and vendors.[2]
The sole implementation is produced by The PHP Group and released under the PHP License. It is considered to be free software by the Free Software Foundation. This implementation serves to define a de facto standard for PHP, as there is no formal specification.
History
PHP was written as a set of CGI binaries in the C programming language by the Danish-Canadian programmer Rasmus Lerdorf in 1994, to replace a small set of Perl scripts he had been using to maintain his personal homepage.[3] Lerdorf initially created PHP to display his résumé and to collect certain data, such as how much traffic his page was receiving. "Personal Home Page Tools" was publicly released on June 8, 1995 after Lerdorf combined it with his own Form Interpreter to create PHP/FI (this release is considered PHP version 2).[4][5]
Zeev Suraski and Andi Gutmans, two Israeli developers at the Technion - Israel Institute of Technology, rewrote the parser in 1997 and formed the base of PHP 3, changing the language's name to the recursive initialism "PHP: Hypertext Preprocessor". The development team officially released PHP/FI 2 in November 1997 after months of beta testing. Public testing of PHP 3 began immediately and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite of PHP's core, producing the Zend Engine in 1999.[6] They also founded Zend Technologies in Ramat Gan, Israel, which actively manages the development of PHP.
In May 2000, PHP 4, powered by the Zend Engine 1.0, was released. The latest version as of December 2006 is 4.4.4. PHP 4 is currently still supported by security updates for those applications that require it.
On July 13, 2004, PHP 5 was released, powered by the new Zend Engine II. PHP 5 included new features such as:[7]
* Robust support for Object-Oriented Programming
* The PHP Data Objects extension, which defines a lightweight and consistent interfaces for accessing databases
* Performance enhancements taking advantage of the new engine
* Better support for MySQL through a completely rewritten extension
* Embedded support for SQLite
* Integrated SOAP support
* Data iterators
* Error handling through Exceptions
The latest version as of January 2007 is PHP 5.2.0.
[edit] Usage
PHP generally runs on a web server, taking PHP code as its input and creating Web pages as output, but command-line scripting and client-side GUI applications are part of the three primary uses of PHP as well. PHP can be deployed on any web server and on almost every OS platform free of charge. The PHP Group also provides the complete source code for users to build, customize and extend for their own use.
[edit] Server-side scripting
Originally designed to create dynamic web pages, PHP's principal focus is server-side scripting. While running the PHP parser with a web server and web browser, the PHP model can be compared to other server-side scripting languages such as Microsoft's ASP.NET system, Adobe ColdFusion, Sun Microsystems' JavaServer Pages, Apple's WebObjects, Zope, mod_perl and the Ruby on Rails framework, as they all provide dynamic content to the client from a web server. To more directly compete with the "framework" approach taken by these systems, Zend is working on the Zend Framework - an emerging (as of June 2006) set of PHP building blocks and best practices; other PHP frameworks along the same lines include CakePHP and Symfony.
The LAMP architecture has become popular in the Web industry as a way of deploying inexpensive, reliable, scalable, secure web applications. PHP is commonly used as the P in this bundle alongside Linux, Apache and MySQL. PHP can be used with a large number of relational database management systems, runs on all of the most popular web servers and is available for many different operating systems. This flexibility means that PHP has a wide installation base across the Internet; over 18 million Internet domains are currently hosted on servers with PHP installed.[8]
Examples of popular server-side PHP applications include phpBB, WordPress and MediaWiki.
[edit] Command-line scripting
PHP also provides a command line interface SAPI for developing shell and desktop applications, log parsing, or other system administration tasks. It is increasingly used on the command line for tasks that have traditionally been the domain of Perl, Python, awk, or shell scripting.
[edit] Client-side GUI applications
PHP provides bindings to GUI libraries such as GTK+ and text mode libraries like ncurses in order to facilitate development of a broader range of cross-platform GUI applications.
WinBinder Also provide windows bindings for php to make windows application utilizing the WinAPI
[edit] Syntax
Wikibooks
Wikibooks Programming has more about this subject:
PHP
PHP primarily acts as a filter. The PHP program takes input from a file or stream containing text and special PHP instructions and outputs another stream of data for display. As of PHP 4, the PHP parser compiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor.
The usual Hello World code example for PHP is:
echo 'Hello, World!';
?>
PHP only parses code within its delimiters, such as . Anything outside its delimiters is sent directly to the output and not parsed by PHP. The example above is equivalent to the following text (and indeed is converted into this form):
Hello, World!
The primary use of this is to allow PHP statements to be embedded within HTML documents, for example:
// PHP statements here
?>
Regular HTML here
// More PHP Statements
?>
Variables are prefixed with a dollar symbol and a type does not need to be specified in advance. Unlike function and class names, variable names are case sensitive. Both double-quoted ("") and heredoc strings allow the ability to embed the variable's value into the string.
PHP treats new lines as whitespace, in the manner of a free-form language (except when inside string quotes). Statements are terminated by a semicolon, except in a few special cases.
PHP has three types of comment syntax: it allows multi-line comments using the /* */ construction as in C, and also allows comments which terminate at the end of the line using the // and # characters (as in C++ and Perl respectively).
[edit] Data types
PHP stores whole numbers in a platform-dependent range. This range is typically that of 32-bit signed integers. Integer variables can be assigned using decimal (positive and negative), octal and hexadecimal notations. Real numbers are also stored in a platform-specific range. They can be specified using floating point notation, or two forms of scientific notation.
PHP has a native Boolean type, named "boolean", similar to the native Boolean types in Java and C++. Using the Boolean type conversion rules, non-zero values can be interpreted as true and zero as false, as in Perl.
The null data type represents a variable that has no value. The only value in the null data type is NULL.
Variables of the "resource" type represent references to resources from external sources. These are typically created by functions from a particular extension, and can only be processed by functions from the same extension. Examples include file, image and database resources.
Arrays support both numeric and string indices, and are heterogeneous. Arrays can contain elements of any type that PHP can handle, including resources, objects, and even other arrays. Order is preserved in lists of values and in hashes with both keys and values, and the two can be intermingled.
[edit] Objects
Basic object-oriented functionality was added in PHP 3. However, handling of objects was completely rewritten for PHP 5, allowing for better performance and more features. In previous versions of PHP, objects were handled like primitive types. The drawback of this method was that semantically the whole object was copied when a variable was assigned, or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not by value. PHP 5 introduced private and protected member variables and methods, along with abstract classes and abstract methods. It also introduced a standard way of declaring constructors and destructors similar to that of other object-oriented languages, such as C++, and an exception handling model similar to that of other programming languages.
The static method and class variable features in Zend Engine 2 do not work the way some expect. There is no virtual table feature in the engine, so the static variables are bound with a name at compile time instead of with a reference.
If the developer asks to create a copy of an object by using the reserved word clone, the Zend engine will check if a __clone() method has been defined or not. If not, it will call a default __clone() which will copy all of the object's properties. If a __clone() method is defined, then it will be responsible to set the necessary properties in the created object. For convenience, the engine will supply a function that imports all of the properties from the source object, so that they can start with a by-value replica of the source object, and only override properties that need to be changed.
[edit] Resources
[edit] Libraries
Main article: List of PHP libraries
PHP includes a large number of free and open source libraries with the core build. PHP is a fundamentally Internet-aware system with modules built in for accessing FTP servers, many database servers, embedded SQL libraries such as embedded MySQL and SQLite, LDAP servers, and others. Many functions familiar to C programmers such as those in the stdio family are available in the standard PHP build.
PHP extensions have been written to add support for the Windows API, process management on Unix-like operating systems, multibyte strings (Unicode), cURL, and several popular compression formats. Some more unusual features include integration with Internet relay chat, and dynamic generation of images and Adobe Flash content. Some additional extensions are available via the PHP Extension Community Library.
[edit] Source code Encoders, Optimizers and Accelerators
As with many scripting languages, PHP scripts are normally kept as human-readable source code, even on production webservers. While this allows flexibility, it can raise issues with security and performance.
Encoders offer some source code security and enable proprietary software by hindering source code reverse engineering. Encoders fall broadly into two types; those that hide source code and those that compile code into bytecode. The downside of this latter approach is that a special extension has to be installed on the server in order to run encoded scripts, however the approach of encoding compiled code and use of an extension offers typically the best performance, security and opportunity for additional features that may be useful for developers. Compiled code solutions may exploit the potential for increased security through the use of their own execution engine, although some simpler solutions rely on the regular PHP engine to execute the compiled code. The most commonly used packages for source code protection are from Zend Technologies and ionCube Ltd.
Code optimizers improve the quality of the compiled code by reducing its size and making changes that can reduce the execution time and improve performance. The nature of the PHP compiler is such that there are often many opportunities for code optimization.
Accelerators offer performance gains by caching the compiled form of a PHP script in shared memory to avoid the overhead of parsing and compiling the code every time the script is run. They may also perform code optimization to provide increased execution performance. Both commercial (e.g. Zend Platform) and open source accelerators (e.g. xcache, eAccelerator, APC) are available.
[edit] Debuggers and profilers
PHP debuggers and profilers allow PHP developers to quickly and accurately analyse PHP code for potential and noted problems and bottlenecks. Examples include APD and Xdebug.
[edit] Templating engines
Templating engines provide macros that allow PHP applications to uniformly identify common variables. One popular templating engine is Smarty.
[edit] PEAR
The PHP Extension and Application Repository (PEAR) project aims to provide reusable libraries and components for PHP development. PEAR projects are usually written in PHP code using the Object-oriented programming paradigm.
[edit] PECL
The PHP Extension Community Library (PECL) project provides extensions to the PHP language. PECL extensions are written generally in C, using the Procedural programming paradigm.
[edit] Support
PHP has a formal development manual that is maintained by the free software community. In addition, answers to many questions can often be found by doing a simple internet search. PHP users assist each other through various media such as chat, forums, newsgroups and PHP developer web sites. In turn, the PHP development team actively participates in such communities, garnering assistance from them in their own development effort (PHP itself) and providing assistance to them as well. There are many help resources available for the novice PHP programmer.
[edit] Criticism
The neutrality of this section is disputed.
Please see the discussion on the talk page.
Criticisms of PHP include those general criticisms ascribed to other scripting languages and dynamically typed languages. This list includes criticisms that have been rectified in recent versions.
* PHP has traditionally inserted data received over the network directly into the language namespace ("register_globals"), leading to confusion between trusted and untrusted data, and hence innumerable security holes in PHP applications. However, this behavior was turned off by default in 4.2.0 and later.[9]
* PHP has traditionally used features such as "magic_quotes_gpc" and "magic_quotes_runtime" which attempt to escape apostrophes (') and quotes (") in strings in the assumption that they will be used in databases, to prevent SQL injection attacks. This leads to confusion over which data is escaped and which is not, and to problems when data is not in fact used as input to a database. [10]
* PHP does not have native support for Unicode or multibyte strings. [11]
* PHP does not enforce the declaration of variables prior to their use, and variables which have not been initialized can have operations (such as concatenation) performed on them; an operation on an uninitialized variable raises an E_NOTICE level error, but this is hidden by default.
* PHP has no namespace support, with all PHP functions sharing the same global namespace.
* PHP's dynamic type conversion could potentially cause problems. Variable types in PHP, although they exist, are transparent to the programmer. Some may consider this a feature, as a variable can change from int to double and back again without extra lines of code. However, variable type errors are not detected at compile-time, and the dynamic-typing behavior lacks full predictability.
* The standard function library lacks internal consistency. Many functions perform relatively similar actions and have different name standards and argument orders. For example, strpos($haystack, $needle) vs. in_array($needle, $haystack), and strcasecmp vs. stristr.
[edit] Future development
PHP 6, in development as of October 2006, aims to address some of PHP 5's shortcomings.[12]
* Native Unicode support will be added;
* The magic_quotes option will be removed;
* The register_globals option will be removed;
* The safe_mode option will be removed.
In addition, there has been discussion of adding namespace support.
PHP competes with other programming languages such as Perl, Ruby, and Python; as of December 2006, it is ranked 5th, down from 4th last year, by TIOBE Programming Community Index. The rankings are based on world wide availability of practitioners, courses and vendors.[2]
The sole implementation is produced by The PHP Group and released under the PHP License. It is considered to be free software by the Free Software Foundation. This implementation serves to define a de facto standard for PHP, as there is no formal specification.
History
PHP was written as a set of CGI binaries in the C programming language by the Danish-Canadian programmer Rasmus Lerdorf in 1994, to replace a small set of Perl scripts he had been using to maintain his personal homepage.[3] Lerdorf initially created PHP to display his résumé and to collect certain data, such as how much traffic his page was receiving. "Personal Home Page Tools" was publicly released on June 8, 1995 after Lerdorf combined it with his own Form Interpreter to create PHP/FI (this release is considered PHP version 2).[4][5]
Zeev Suraski and Andi Gutmans, two Israeli developers at the Technion - Israel Institute of Technology, rewrote the parser in 1997 and formed the base of PHP 3, changing the language's name to the recursive initialism "PHP: Hypertext Preprocessor". The development team officially released PHP/FI 2 in November 1997 after months of beta testing. Public testing of PHP 3 began immediately and the official launch came in June 1998. Suraski and Gutmans then started a new rewrite of PHP's core, producing the Zend Engine in 1999.[6] They also founded Zend Technologies in Ramat Gan, Israel, which actively manages the development of PHP.
In May 2000, PHP 4, powered by the Zend Engine 1.0, was released. The latest version as of December 2006 is 4.4.4. PHP 4 is currently still supported by security updates for those applications that require it.
On July 13, 2004, PHP 5 was released, powered by the new Zend Engine II. PHP 5 included new features such as:[7]
* Robust support for Object-Oriented Programming
* The PHP Data Objects extension, which defines a lightweight and consistent interfaces for accessing databases
* Performance enhancements taking advantage of the new engine
* Better support for MySQL through a completely rewritten extension
* Embedded support for SQLite
* Integrated SOAP support
* Data iterators
* Error handling through Exceptions
The latest version as of January 2007 is PHP 5.2.0.
[edit] Usage
PHP generally runs on a web server, taking PHP code as its input and creating Web pages as output, but command-line scripting and client-side GUI applications are part of the three primary uses of PHP as well. PHP can be deployed on any web server and on almost every OS platform free of charge. The PHP Group also provides the complete source code for users to build, customize and extend for their own use.
[edit] Server-side scripting
Originally designed to create dynamic web pages, PHP's principal focus is server-side scripting. While running the PHP parser with a web server and web browser, the PHP model can be compared to other server-side scripting languages such as Microsoft's ASP.NET system, Adobe ColdFusion, Sun Microsystems' JavaServer Pages, Apple's WebObjects, Zope, mod_perl and the Ruby on Rails framework, as they all provide dynamic content to the client from a web server. To more directly compete with the "framework" approach taken by these systems, Zend is working on the Zend Framework - an emerging (as of June 2006) set of PHP building blocks and best practices; other PHP frameworks along the same lines include CakePHP and Symfony.
The LAMP architecture has become popular in the Web industry as a way of deploying inexpensive, reliable, scalable, secure web applications. PHP is commonly used as the P in this bundle alongside Linux, Apache and MySQL. PHP can be used with a large number of relational database management systems, runs on all of the most popular web servers and is available for many different operating systems. This flexibility means that PHP has a wide installation base across the Internet; over 18 million Internet domains are currently hosted on servers with PHP installed.[8]
Examples of popular server-side PHP applications include phpBB, WordPress and MediaWiki.
[edit] Command-line scripting
PHP also provides a command line interface SAPI for developing shell and desktop applications, log parsing, or other system administration tasks. It is increasingly used on the command line for tasks that have traditionally been the domain of Perl, Python, awk, or shell scripting.
[edit] Client-side GUI applications
PHP provides bindings to GUI libraries such as GTK+ and text mode libraries like ncurses in order to facilitate development of a broader range of cross-platform GUI applications.
WinBinder Also provide windows bindings for php to make windows application utilizing the WinAPI
[edit] Syntax
Wikibooks
Wikibooks Programming has more about this subject:
PHP
PHP primarily acts as a filter. The PHP program takes input from a file or stream containing text and special PHP instructions and outputs another stream of data for display. As of PHP 4, the PHP parser compiles input to produce bytecode for processing by the Zend Engine, giving improved performance over its interpreter predecessor.
The usual Hello World code example for PHP is:
echo 'Hello, World!';
?>
PHP only parses code within its delimiters, such as . Anything outside its delimiters is sent directly to the output and not parsed by PHP. The example above is equivalent to the following text (and indeed is converted into this form):
Hello, World!
The primary use of this is to allow PHP statements to be embedded within HTML documents, for example:
// PHP statements here
?>
Regular HTML here
// More PHP Statements
?>
Variables are prefixed with a dollar symbol and a type does not need to be specified in advance. Unlike function and class names, variable names are case sensitive. Both double-quoted ("") and heredoc strings allow the ability to embed the variable's value into the string.
PHP treats new lines as whitespace, in the manner of a free-form language (except when inside string quotes). Statements are terminated by a semicolon, except in a few special cases.
PHP has three types of comment syntax: it allows multi-line comments using the /* */ construction as in C, and also allows comments which terminate at the end of the line using the // and # characters (as in C++ and Perl respectively).
[edit] Data types
PHP stores whole numbers in a platform-dependent range. This range is typically that of 32-bit signed integers. Integer variables can be assigned using decimal (positive and negative), octal and hexadecimal notations. Real numbers are also stored in a platform-specific range. They can be specified using floating point notation, or two forms of scientific notation.
PHP has a native Boolean type, named "boolean", similar to the native Boolean types in Java and C++. Using the Boolean type conversion rules, non-zero values can be interpreted as true and zero as false, as in Perl.
The null data type represents a variable that has no value. The only value in the null data type is NULL.
Variables of the "resource" type represent references to resources from external sources. These are typically created by functions from a particular extension, and can only be processed by functions from the same extension. Examples include file, image and database resources.
Arrays support both numeric and string indices, and are heterogeneous. Arrays can contain elements of any type that PHP can handle, including resources, objects, and even other arrays. Order is preserved in lists of values and in hashes with both keys and values, and the two can be intermingled.
[edit] Objects
Basic object-oriented functionality was added in PHP 3. However, handling of objects was completely rewritten for PHP 5, allowing for better performance and more features. In previous versions of PHP, objects were handled like primitive types. The drawback of this method was that semantically the whole object was copied when a variable was assigned, or passed as a parameter to a method. In the new approach, objects are referenced by handle, and not by value. PHP 5 introduced private and protected member variables and methods, along with abstract classes and abstract methods. It also introduced a standard way of declaring constructors and destructors similar to that of other object-oriented languages, such as C++, and an exception handling model similar to that of other programming languages.
The static method and class variable features in Zend Engine 2 do not work the way some expect. There is no virtual table feature in the engine, so the static variables are bound with a name at compile time instead of with a reference.
If the developer asks to create a copy of an object by using the reserved word clone, the Zend engine will check if a __clone() method has been defined or not. If not, it will call a default __clone() which will copy all of the object's properties. If a __clone() method is defined, then it will be responsible to set the necessary properties in the created object. For convenience, the engine will supply a function that imports all of the properties from the source object, so that they can start with a by-value replica of the source object, and only override properties that need to be changed.
[edit] Resources
[edit] Libraries
Main article: List of PHP libraries
PHP includes a large number of free and open source libraries with the core build. PHP is a fundamentally Internet-aware system with modules built in for accessing FTP servers, many database servers, embedded SQL libraries such as embedded MySQL and SQLite, LDAP servers, and others. Many functions familiar to C programmers such as those in the stdio family are available in the standard PHP build.
PHP extensions have been written to add support for the Windows API, process management on Unix-like operating systems, multibyte strings (Unicode), cURL, and several popular compression formats. Some more unusual features include integration with Internet relay chat, and dynamic generation of images and Adobe Flash content. Some additional extensions are available via the PHP Extension Community Library.
[edit] Source code Encoders, Optimizers and Accelerators
As with many scripting languages, PHP scripts are normally kept as human-readable source code, even on production webservers. While this allows flexibility, it can raise issues with security and performance.
Encoders offer some source code security and enable proprietary software by hindering source code reverse engineering. Encoders fall broadly into two types; those that hide source code and those that compile code into bytecode. The downside of this latter approach is that a special extension has to be installed on the server in order to run encoded scripts, however the approach of encoding compiled code and use of an extension offers typically the best performance, security and opportunity for additional features that may be useful for developers. Compiled code solutions may exploit the potential for increased security through the use of their own execution engine, although some simpler solutions rely on the regular PHP engine to execute the compiled code. The most commonly used packages for source code protection are from Zend Technologies and ionCube Ltd.
Code optimizers improve the quality of the compiled code by reducing its size and making changes that can reduce the execution time and improve performance. The nature of the PHP compiler is such that there are often many opportunities for code optimization.
Accelerators offer performance gains by caching the compiled form of a PHP script in shared memory to avoid the overhead of parsing and compiling the code every time the script is run. They may also perform code optimization to provide increased execution performance. Both commercial (e.g. Zend Platform) and open source accelerators (e.g. xcache, eAccelerator, APC) are available.
[edit] Debuggers and profilers
PHP debuggers and profilers allow PHP developers to quickly and accurately analyse PHP code for potential and noted problems and bottlenecks. Examples include APD and Xdebug.
[edit] Templating engines
Templating engines provide macros that allow PHP applications to uniformly identify common variables. One popular templating engine is Smarty.
[edit] PEAR
The PHP Extension and Application Repository (PEAR) project aims to provide reusable libraries and components for PHP development. PEAR projects are usually written in PHP code using the Object-oriented programming paradigm.
[edit] PECL
The PHP Extension Community Library (PECL) project provides extensions to the PHP language. PECL extensions are written generally in C, using the Procedural programming paradigm.
[edit] Support
PHP has a formal development manual that is maintained by the free software community. In addition, answers to many questions can often be found by doing a simple internet search. PHP users assist each other through various media such as chat, forums, newsgroups and PHP developer web sites. In turn, the PHP development team actively participates in such communities, garnering assistance from them in their own development effort (PHP itself) and providing assistance to them as well. There are many help resources available for the novice PHP programmer.
[edit] Criticism
The neutrality of this section is disputed.
Please see the discussion on the talk page.
Criticisms of PHP include those general criticisms ascribed to other scripting languages and dynamically typed languages. This list includes criticisms that have been rectified in recent versions.
* PHP has traditionally inserted data received over the network directly into the language namespace ("register_globals"), leading to confusion between trusted and untrusted data, and hence innumerable security holes in PHP applications. However, this behavior was turned off by default in 4.2.0 and later.[9]
* PHP has traditionally used features such as "magic_quotes_gpc" and "magic_quotes_runtime" which attempt to escape apostrophes (') and quotes (") in strings in the assumption that they will be used in databases, to prevent SQL injection attacks. This leads to confusion over which data is escaped and which is not, and to problems when data is not in fact used as input to a database. [10]
* PHP does not have native support for Unicode or multibyte strings. [11]
* PHP does not enforce the declaration of variables prior to their use, and variables which have not been initialized can have operations (such as concatenation) performed on them; an operation on an uninitialized variable raises an E_NOTICE level error, but this is hidden by default.
* PHP has no namespace support, with all PHP functions sharing the same global namespace.
* PHP's dynamic type conversion could potentially cause problems. Variable types in PHP, although they exist, are transparent to the programmer. Some may consider this a feature, as a variable can change from int to double and back again without extra lines of code. However, variable type errors are not detected at compile-time, and the dynamic-typing behavior lacks full predictability.
* The standard function library lacks internal consistency. Many functions perform relatively similar actions and have different name standards and argument orders. For example, strpos($haystack, $needle) vs. in_array($needle, $haystack), and strcasecmp vs. stristr.
[edit] Future development
PHP 6, in development as of October 2006, aims to address some of PHP 5's shortcomings.[12]
* Native Unicode support will be added;
* The magic_quotes option will be removed;
* The register_globals option will be removed;
* The safe_mode option will be removed.
In addition, there has been discussion of adding namespace support.
Subscribe to:
Posts (Atom)