About PHP what files to use which software can open the _php tutorial

Source: Internet
Author: User
Tags html header
What is PHP file? which software can be used to open
PHP, a nested abbreviated name, is an abbreviation for the English Super Text preprocessing language (Php:hypertext preprocessor). PHP is an HTML embedded language, PHP and Microsoft's ASP quite a bit similar, is a server-side implementation of embedded HTML document scripting language, language style has similar to C language, is now widely used by many web site programmers. PHP's unique syntax mixes C, Java, Perl, and PHP's self-innovative syntax. It can perform dynamic Web pages more quickly than CGI or Perl. Dynamic pages made with PHP are compared to other programming languages, and PHP is executed in an HTML document, which is much more efficient than CGI, which is also embedded in the HTML document, and PHP is executed on the server side, compared to the scripting language JavaScript Take full advantage of the performance of the server, the PHP execution engine will also be the user frequently access to the PHP program in memory, other users do not need to recompile the program once again to access the program, as long as the direct execution of in-memory code, which is the embodiment of PHP efficiency. PHP has a very powerful feature, all CGI or JavaScript functionality PHP can be implemented, and support almost all the popular database and operating system. PHP Open Source Code

PHP was originally created in 1994 by Rasmus Lerdorf, just beginning with a simple Perl-language program to count visitors to his own site. It was later rewritten in C, including access to the database. Starting with personal Home Page tools (PHP Tools) in 1995, Lerdorf wrote some documents describing the program and released PHP1.0. In this early version, the guest message book, guest counter and other simple functions are provided. More and more Web sites later use PHP, and strongly want to add some features, such as looping statements and arrays of variables, etc., after the new members joined the development ranks, in 1995 years, PHP2.0 released. The second edition is named PHP/FI (Form interpreter). Php/fi joined the support for mSQL, and has since established PHP's position in Dynamic web development. By the end of 1996, there were 15,000 websites using PHP/FI, and in 1997 years the number of sites using PHP/FI was more than 50,000. In the 1997 years, the third edition of the development Plan began, the development team joined Zeev Suraski and Andi Gutmans, and the third edition was named PHP3. In the 2000, PHP4.0 was introduced, which added a lot of new sex. OSPHP.COM.Cn Open Source

Features of PHP include:

Open Source: All of the PHP source code is actually available.

PHP is free of charge.

Server-based: PHP is a server-side script that can run under UNIX, LINUX, and Windows.

Embed HTML: Because PHP can embed HTML language, it's not difficult to learn.

Simple language: PHP insists that scripting language is the main, unlike Java in C + +.

High efficiency: PHP consumes a fairly small amount of system resources.

Image processing: Creating images dynamically with PHP

PHP 3 vs. PHP 4

PHP3 is closely integrated with the Apache server, plus it constantly updates and adds new features, and almost all mainstream and non-mainstream databases, and with its high-speed execution efficiency, PHP has more than 1.5 billion sites in 1999 years. Plus its source code is completely open, in the open source awareness of today, it is the mainstay of this. With the addition of new libraries, and the dynamic of constant updates, PHP can have more new features on UNIX, Linux, or Windows platforms. It provides a rich range of functions, which allows for better support in program design. PHP Open Source Code

PHP4.0 the core of the entire scripting program, allowing the program to execute faster and meet the demands of the process. The efficiency after optimization has been better than the traditional CGI or ASP programs. And there are stronger new features, richer libraries of functions. Whether you accept it or not, PHP will be a top-of-the-range revolution in Web CGI. It will also be one of the required courses for a professional web Master.

PHP 4.0 is a more efficient, more reliable Dynamic Web page development tool that runs faster than PHP 3.0 in most cases, its script description is more powerful and more complex, and the most notable feature is the increase in rate ratio. PHP4.0 These excellent performance is the result of a redesign of the PHP scripting engine: The engine is completely rewritten by Andigutmans and Zeev Suraski from the bottom. The PHP4.0 scripting engine--zend engine uses a more efficient compilation-execution method rather than the execution of PHP 3.0-when parsing the model.

PHP4 has added or enhanced many useful features on the basis of version 3.0, mainly as follows:

(1) Aliases: In PHP4, you can use references to assign values to variables, which gives you a lot of flexibility in programming.

(2) Expanded API module: PHP 4.0 provides an extended PHP interface module for the Extended API module, which is significantly faster than the old API version. Most of the existing and most commonly used interfaces for PHP modules are converted to interfaces that use this extension.

(3) Automatic resource release: PHP4 adds the reference counting function, the introduction of this new technology enables PHP4 to have automatic memory management function, reducing the burden on developers.

(4) Boolean type: PHP 4.0 supports Boolean type.

(5) Process generation: PHP 4.0 in the UNIX environment provides a very intelligent and common build process, using a system generation technology called Automake/libtool-based.

(6) com/dcom support: PHP 4.0 provides com/dcom support (for Windows environments only) to seamlessly access and access COM objects.

(7) Compatibility with PHP 3.0 is good: PHP 4.0 is close to 100% backwards compatibility with PHP 3.0 code. Due to the improved architecture of PHP 4, there are some subtle differences between the two, but most people will probably never be able to meet this situation.


Introduction to PHP

(8) Configuration: PHP4 redesigned and enhanced PHP. INI file, which makes use of PHP. INI to configure PHP is extremely easy, this file can be registered at runtime by Apache (Unix system) or by Windows (Windows environment).

(9) Encryption support: PHP4 implements full encryption, which is a complete mycrypt library, and PHP 4.0 supports hash functions. BLOWFISH,TRIPLEDES,MD5, and SHA1 is also a number of cryptographic algorithms that can be used.

(10) Type check: PHP 4.0 supports the same operator for type checking: = = = (3 equals operator) for checking between two values and their types. For example, 3 ===3 will be considered false (the type is different), and 3 ==3 (equal judgment) will be considered true.

(one) FTP support: PHP 4.0 supports FTP. Typically, you will provide an interface for downloading a large file over a modem connection. However, if you do have a need, you can use PHP.

PHP4 new function or function enhancement function: PHP 4.0 has added a number of functions, but also many existing functions have been enhanced, the following are some examples. Array_count_values () eval () foreach () nclude () Ob_end_clean () Ob_end_flush () ob_get_contents () Ob_start () Strip_tags () Unset ()
Open Source OSPhP.COM.CN

Here Print: The here print for PHP 4.0 is similar to Perl, albeit completely different. Here is a useful way to print bulk articles, such as in an HTML file, without missing any characters, such as directory tags.

HTTP session fallback system: A fallback system for HTTP session management is implemented in PHP 4.0. By default, the session identifier is stored by the cookie. If there is no cookie support or a cookie task fails, the session identifier is automatically created and carried in the URL's query string.

(a) ISAPI support: PHP 4.0 can be used as a personalized ISAPI module as an IIS plugin. This is more efficient than PHP 3.0, which runs as an external program.

(16) Memory: PHP 4.0 More efficient use of memory, resulting in less memory consumption, mainly due to the implementation of reference counting technology.

(17) Other class member functions: In PHP 4.0 you can call member functions of other classes within the scope or global scope of the member function itself. For example, you can overwrite a parent function with a child function and call the parent function in a child function. Open Source OSPhP.COM.CN

(18) Multidimensional array: In PHP 4.0, a multidimensional array is supported by data transmission using get,post,cookies.

(19) Personalized HTTP Session support: HTTP session processing, including fallback system management, in PHP 4.0 is implemented by its new library functions. Processing session in version 3.0 requires the use of phplib and third-party library functions, which are much slower than the session directly supported by PHP.

(20) Personalized Java support: PHP 4.0 supports and Java interaction. This personalized Java support provides a simple and effective tool for PHP to create and use methods on Java objects.

21) objects and nested groups: PHP 4.0 implements a more powerful object, removing the syntactic limitations that PHP 3.0 has. objects can be nested within an array and vice versa, and can be nested according to your needs.

(22) Object-oriented programming: PHP 4.0 provides extended functionality and new features for object-oriented programming and construction classes and objects. PHP4 implements the object overloading, referencing technology and other new technologies.

(23) Object overloading Support: Object overloading syntax allows third-party object-based class libraries to access their own functionality using PHP4 's object-oriented features. A COM module using this feature has been implemented.
PHP Open Source Code

(24) Output buffering support: PHP provides a set of output buffering functions. Output buffering support allows you to write wrap function functions to compress buffers. Output buffering support in PHP4 allows HTML header information to be stored, regardless of whether the body of the HTML is output. Header information (header (), content type, and cookies) does not use buffering.

(25) Added PCRE Library: PHP 4.0 includes a Perl-compatible regular expression (PCRE) library that binds to PHP with the normal regex library. Split and replace PCRE features are supported. There are some subtle differences between PCRE and Perl regular expressions.

(+) php.ini file: php.ini file was redesigned in PHP4.0, using the configuration of PHP php.ini is easier and more efficient. All files can be operated by Apache at run time (in Apache environment) or by Windows Registry (under Windows). The configuration instructions that are added to the php.ini file are automatically supported in all relevant modules.

(27) Reference count: PHP 4.0 provides a reference count for each value in the system, including resources. Once a resource is no longer referenced by any variable, it is automatically freed to conserve memory resources. The most obvious example of this feature is a looping statement with a built-in SQL query. In PHP 3.0, each time a separate SQL result set is recursively requested for memory, the memory consumed by the resulting collection is freed until the script executes. Open Source OSPhP.COM.CN

(28) Support references: You can change the value of a variable by reference.

(29) Run-time binding of functions: PHP 4.0 's runtime binding allows you to invoke them before they are declared, whether or not they are declared after the code or at run time.

(30) Runtime information for classes: PHP 4.0 supports access to the following class information at run time: the class name of an object, the class name of the parent class of an object, and the name of the object function.

(31) Server Abstraction Layer: Provides an enhanced SAPI (server API) interface to support Web servers, PHP 4. 0 non-divided part. This server abstraction layer provides common Web server interface support, supports multi-threaded Web servers, and provides transparent support for most Web servers, including Apache, IIS (ISAPI), and AOL servers.

(32) The syntax of the light display: PHP 4.0 syntax of the light display allows developers to see the source code rather than the script, this function than PHP 3. 0 is more efficient. It runs faster, executes better, and produces more compact HTML code.
PHP Open Source Code

(33) The value of the variable is changed by reference: PHP 4.0 supports variable assignment by reference, the value of any one of the 2 variables of "association" is changed, and the value of the other variable is also changed, which is similar to the pointer type in C.

(34) A variable reference in a reference string: PHP 4.0 enhances the reference to a variable in the reference string.

PHP's extensive support of the database is also one of the reasons for its rapid popularity, which supports the following databases or data files:

· Adabas D
· Dba
· DBase
· Dbm
· Filepro
· Informix
· InterBase
· Microsoft SQL Server
· Mysql
· Solid
· Sybase
· Odbc
· Oracle 8
· Oracle
· PostgreSQL

And on the Internet it also supports a considerable number of communication protocols (protocol), including e-mail-related IMAP, POP3; network news NNTP; account sharing NIS; Global information Network HTTP and Apache server; directory Protocol LDA P and other related functions of the network.

In addition, the Web back-end CGI program written in PHP can be easily ported to different operating systems. For example, a Linux-based Web site can quickly move the entire system to a SUN workstation without recompiling the CGI program when the system is overloaded. Facing the fast-growing Internet, this is the best choice for long-term planning.
Open Source Code OSPHP.COM.Cn

Variable type:
PHP has a good variety of variables; There are mainly these:
-Number (integer-Example: 32)
-Bollinger Bands (Boolean-Example: TRUE)
-Strings (String-Example: ' A string of text ')
-Resources (Resource)
-Array (Array-example: Arrayname[2])


There are three types of syntax:
/* Comment */
# comment

Basic "Control Structures":

* If ... else
if (condition = = true);
* If ... else then
if (condition = = true)
else if (Condition2 = = true);

A PHP instance:

echo "Hello World";


Please see:
PHP official website: [url=http://www.php.net/] link tag Www.php.net[/url]
PHP support for object-oriented
The concept of object-oriented programming:
Different authors may disagree, but an OOP language must have the following:
Abstract data types and information encapsulation
In PHP, the encapsulation is done through a class:

Class Something {
In an OOP class, the first character is usually capitalized
var $x;
function SetX ($v) {
Method starts with a lowercase word, and then uses uppercase letters to separate words, such as Getvalueofarea ()
$this->x= $v;

function GetX () {
return $this->x;

Of course you can define your preferences, but it's better to keep a standard, which is more effective. Data members are defined in a class using the "var" declaration, which is not typed until the data member is assigned a value. A data member can be an integer, an array, an associated array (associative array), or an object. method is defined as a function in a class, you should use $this->name when accessing a class member variable in a method, otherwise it can only be a local variable for a method.
OSPHP.COM.Cn Open Source

Use the new operator to create an object:
$obj =new Something;

You can then use the member function to pass:

$obj->setx (5);
$see = $obj->getx ();

In this example, the SETX member function assigns 5 to the object's member variable x (not the Class), and then Getx returns its value 5. It is not a good OOP habit to access data members by way of a class reference like $obj->x=6. I strongly recommend accessing member variables through methods. If you consider the member variable to be non-processing and use the method only through the object handle, you will be a good OOP programmer. Unfortunately, PHP does not support declaring private member variables, so bad code is also allowed in PHP. Inheritance is easy to implement in PHP, as long as the Extend keyword is used.

Class Another extends Something {
var $y;

function Sety ($v) {
$this->y= $v;

function GetY () {
return $this->y;



Objects of the "another" class now have all the data members and methods of the parent class (Something), plus their own data members and methods.

You can use
$obj 2=new Something;
$obj 2->setx (6);
$obj 2->sety (7);

PHP does not now support multiple inheritance, so you cannot derive new classes from two or more of the two classes. You can redefine a method in a derived class, and if we redefine the Getx method in the "Another" class, we cannot use the Getx method in "Something". If you declare a data member in a derived class that has the same name as implementation, it will "hide" the data members of the base class when you process it.

You can define constructors in your class. A constructor is a method that has the same name as a class, and is called when you create an object of a class, for example:

Class Something {
var $x;

function Something ($y) {
$this->x= $y;


function SetX ($v) {
$this->x= $v;

function GetX () {
return $this->x;


So you can create an object by:
$obj =new Something (6);

The constructor automatically assigns a value of 6 to the data variable, x. Constructors and methods are normal PHP functions, so you can use the default parameters.

function Something ($x = "3", $y = "5")


$obj =new Something (); X=3 and Y=5
$obj =new Something (8); X=8 and Y=5
$obj =new Something (8,9); X=8 and Y=9

The default parameter uses C + +, so you can't ignore the value of Y, and give X a default parameter, which is assigned from left to right, and if the passed parameter is less than the required parameter, the default parameter is used.

When an object of a derived class is created, only its constructor is called, the constructor of the parent class is not called, and if you want to call the constructor of the base class, you must display the call in the constructor of the derived class. You can do this because the methods of all the parent classes in the derived class are available. OSPHP.COM.CN

function another () {
$this->something ();
Show call base class constructor


A good mechanism for OOP is to use abstract classes. Abstract classes are not instantiated and can only be supplied to a derived class interface. Designers often use abstract classes to force programmers to derive from base classes, which ensures that new classes contain some expected functionality. There is no standard method in PHP, but: if you need this feature, you can define the base class, and add a "die" call after its constructor, so that the base class is not instantiated, and now after each method (interface) with a "Die" statement, so, If a programmer does not overwrite a method in a derived class, an error is raised. And because PHP is untyped, you might want to make sure that an object is derived from your base class, then add a method in the base class to the identity of the literal class (returning an Identity ID), and verify the value when you receive an object parameter. Of course, if an evil, bad programmer overrides this method in a derived class, this method does not work, but the general problem is that it is more of a lazy programmer than an evil one. OsPHP.COM.CN

Of course, it's good for the base class to be impossible for programmers to see, as long as the interface is printed out to do their job. There are no destructors in PHP.

Overloads (unlike overrides) are not supported in PHP. In OOP, you can overload a method to implement two or more methods with the same name, but with different numbers or types of arguments (this depends on the language). PHP is a loosely typed language, so it does not work with type overloading, but overloading with different number of parameters does not work.

Sometimes overloading constructors in OOP is great, so you can create objects in different ways (passing different numbers of parameters). The trick to implementing it in PHP is:

Class Myclass {
function Myclass () {
$name = "Myclass". Func_num_args ();
$this $name ();
Note that $this->name () is generally wrong, but here $name is the name of the method that will be called


function Myclass1 ($x) {//Open source code OSPHP.COM.Cn

function Myclass2 ($x, $y) {


By additional processing in the class, using this class is transparent to the user:

$obj 1=new Myclass (' 1 '); Will call Myclass1
$obj 2=new Myclass (' 1 ', ' 2 '); Will call Myclass2

Sometimes this is very useful.


Polymorphism is the ability of an object to determine the method of which object to invoke, depending on the passed object parameters at run time. For example, if you have a figure class, it defines a draw method. and derive the circle and rectangle classes, in which you override the Draw method, you may also have a function that expects to use a parameter x, and can call $x->draw (). If you have polymorphism, calling which draw method depends on the type of object you pass to the function.

Polymorphism in an interpreted language like PHP (imagine a C + + compiler generating such code, which method should you call?) You also don't know what type of object you have, well, it's not the point, it's very easy and natural. So PHP certainly supports polymorphism. OSPHP.COM.CN

function nicedrawing ($x) {
Suppose this is a method of the Board class
$x->draw ();

$obj =new Circle (3,187);
$obj 2=new Rectangle (4,5);
$board->nicedrawing ($obj);

The draw method that will call circle

$board->nicedrawing ($obj 2);

The draw method that will call rectangle

Object-oriented Programming with PHP

Some "purists" (purists) may say that PHP is not a true object-oriented language, which is true. PHP is a mixed language, you can use OOP, or you can use traditional procedural programming. However, for large projects, you might want to use pure OOP in PHP to declare classes, and only use objects and classes in your project.

As projects grow larger, using OOP can be helpful, and OOP code is easy to maintain, easy to understand and reuse. These are the foundations of software engineering. Applying these concepts to Web-based projects is the key to future site success.
Open Source OSPhP.COM.CN

Advanced OOP Technology for PHP

After reading the basic OOP concepts, I can show you more advanced techniques:

Serialization (serializing)

While PHP does not support persistent objects, permanent objects in OOP are objects that can hold state and functionality in references to multiple apps, which means having the ability to save objects to a file or database, and to load objects later. This is called the serialization mechanism. PHP has a serialization method that can be called through an object, and the serialization method can return a string representation of an object. However, serialization saves only the member data of the object and does not package the session method.

In PHP4, if you serialize an object into a string $s and then release the object, and then deserialize the object to $obj, you can continue to use the object's Method! I do not recommend this because (a) there is no guarantee in the documentation that this behavior will still be available in later versions. (b) This may lead to a misunderstanding when you save a serialized version to disk and exit the script. When you run the script later, you cannot expect the object's methods to be there when deserializing an object, because the string representation does not include the method at all. PHP Open Source Code

In summary, PHP serialization is useful for saving member variables of an object. (You can also serialize related arrays and arrays into a file).


$obj =new Classfoo ();

$str =serialize ($obj);

Save $str to disk

A few months later

Mount Str from disk

$obj 2=unserialize ($STR)

You restored the member data, but did not include the method (according to the document). This leads to access to member variables only by similar use of $obj2->x (you have no other way!). The only way, so don't try it at home.

There are some ways to solve this problem, I keep it, because they are too bad for this concise article. I would be delighted to welcome the full serialization feature in subsequent versions of PHP.

Using classes for data storage PHP and oop a very good thing is that you can easily define a class to manipulate something, and you can invoke the appropriate class whenever you want to use it. Suppose you have an HTML form that allows users to select a product by selecting the Product ID number. In the database has the product information, you want to display the product, show its price and so on. You have different types of products, and the same action may have different meanings for different products. For example, displaying a sound might mean playing it, but for other kinds of products it might mean displaying a picture in the database. You can use OOP or PHP to reduce coding and improve quality://osphp.com.cn

Define a product's class, define the method it should have (for example: Display), and then define the classes for each type of product, from the product class to come out (Sounditem class, Viewableitem class, etc.), covering the methods in the product class so that they act as you think.

A typical product table may have (ID, type, price, description, and so on), depending on the type of each product in the database, given the class name. Then in the processing script, you can remove the type value from the database and instantiate an object named type:

$obj =new $type ();

$obj->action ();

This is a very good feature of PHP, you can not consider the type of object, call $obj display method or other methods. With this technique, you don't need to modify the script to add a new type of object, just add a class that handles it.

This is a powerful feature, as long as you define the method without considering the types of all the objects, implement them in different ways, and then use them in the main script for any object, no if...else, no two programmers, only happy.
Open Source Code OSPhP.COm.CN

Now do you agree that programming is easy, maintenance is cheap, reusable is true?

If you manage a group of programmers, assigning jobs is easy, and everyone can be responsible for one type of object and the class that handles it.

Internationalization can be achieved through this technology, according to the user's chosen language field to apply the corresponding class can be, and so on.

Copy and Clone

When you create a $obj object, you can copy the object through the $obj2= $obj, and the new object is a copy of the $obj (not a reference), so it has a $obj state at that time. Sometimes, you don't want to, you just want to create a new object like the Obj class, you can call the class's constructor by using the new statement. It can also be implemented in PHP by serialization, and a base class, but all other classes are derived from the base class.

Enter hazardous areas

When you serialize an object, you get a string of some format, and if you're interested, you can tune it, where the string has the name of the class (too good!). ), you can take it out, like this:

$herring =serialize ($obj);
$vec =explode (': ', $herring);
$nam =str_replace ("" "," ', $vec [2]);

So suppose you create a "Universe" class and force all classes to be extended from Universe, you can define a clone method in Universe, as follows:

Class Universe {
function Clone () {
$herring =serialize ($this);
$vec =explode (': ', $herring);
$nam =str_replace ("" "," ', $vec [2]);
$ret =new $nam;
return $ret;

And then

$obj =new Something ();
Extending from Universe
$other = $obj->clone ();

What you get is a new object of the Something class, which is the same as using the new method, which calls the constructor to create the object. I don't know if this is useful for you, but the Universe class can know the name of the derived class as a good experience. Imagination is the only limit.

Reference answer
hehe · Happy New Year ·
Very helpful! · hehe ·
Support You ·
Reference answer
Enough Foundation ~[img]http://www.111cn.cn/bbs/images/smilies/default/funk.gif[/img]
Reference answer
Oh... To the novice to see. Very comprehensive!!!!
Reference answer
Say the basics ... Finally, we mention the serialization ...
Reference answer
It seems to be very water.
Reference answer
It's too much water.

http://www.bkjia.com/PHPjc/632575.html www.bkjia.com true http://www.bkjia.com/PHPjc/632575.html techarticle question what is PHP file? With which software can open the workaround PHP, a nested abbreviated name, is the abbreviation of English Super Text preprocessing language (Php:hypertext preprocessor) ...

  • 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.