Home  >  Article  >  Backend Development  >  PHP language

PHP language

不言
不言Original
2018-04-13 10:57:356201browse

The content shared with you in this article is about the PHP language, which has certain reference value. Friends in need can refer to it


1. PHP design Principle


a)Single Responsibility Principle

b)Richter Substitution Principle

c)Dependency Inversion Principle

d) Open and closed principle

e) Interface isolation principle

2. PHP development model

a) Singleton mode b) Factory mode c) Observer mode d) Strategy Pattern

1) Singleton pattern, as the name suggests, means that there is only one instance. As an object creation mode, the singleton mode ensures that a class has only one instance, instantiates itself and provides this instance to the entire system.

There are three main points of the singleton mode:
First, a class can only have one instance; Second, it must create this instance by itself; Third, it must provide this instance to the entire system by itself
Typical representatives are base class objects in the framework
2) Simple factory pattern
①Abstract base class: Some abstract methods are defined in the class to implement them in subclasses
②Inherited from abstract base class Subclass: implement the abstract method in the base class
③ Factory class: used to instantiate all corresponding subclasses
This is the most common one we use, and it is generated in this way in basically all MVC frameworks.

3. PHP operating principle

a) Read the configuration file of php.ini b) Start a php c) Read the index.php file d) Compile Zend Engine (currently PHP's engine only has zend) e) opcode (intermediate code) OPcache // a caching method f) generate the format required for the corresponding http g) recycle and close the process

4. What is the difference between PHP and JAVA

a) Php is a weak class language, Java is a strong class b) Java is safer than Php c) Php’s library functions are written in C, and the library running the core of Java is written in Java

5.What is the highest level among PHP development positions?

a)Php enthusiast b)Php beginner c)Php junior programmer d)Php intermediate programmer e)Php senior programmer f )Php engineer

6. What is the difference between PHP5.6 and PHP7.0?

a)Php7.0 no longer supports mysqli extension

b)Php7.0 is better than Php5. 6. The performance has been improved twice, and 64-bit is fully and consistently supported

c) Many fatal errors in the past are now thrown exceptions

7.404? 500? 302? 301? 400? 501? 200?

404: Page not found

500: Internal server error

302: Temporary redirection

301: Permanent redirection

400: The server does not understand the syntax of the request

501: The server does not have the functionality to complete the request

200: The request was successfully processed

8. In what form does PHP store sessions?

PHP provides three ways to store sessions: file/memory/custom storage. The default is to use file storage. When accessing It is not appropriate to use this method on a large-volume website, because it will cause a lot of input and output redundancy. We can set the storage type of the session file through the corresponding function in the php.ini change configuration file or in the php script. To change the storage form of the session file

9.PHP variable type

Four scalar types:
1)boolean (Boolean): This is the simplest type, with only two A value can be TRUE/true or FALSE/false, and is not case-sensitive. For details, please see: PHP Boolean type (boolean)
2) integer (integer): Its valid range in 32-bit operating systems is: -2 147 483 648~ 2 147 483 647. Integer values ​​can be expressed in decimal, hexadecimal or octal notation and may be preceded by an optional sign (- or ). Octal represents a number that must be preceded by 0 (zero), and hexadecimal represents a number that must be preceded by 0x.
3)float (floating point type, also called double)
4)string (string): Character variables are different from other programming languages ​​in that they are divided into characters and strings. In PHP, characters are used uniformly. type variable to define characters or strings.
Two composite types:
5)array: Array variable is a special variable type, which will be explained in detail in subsequent chapters.
6)object: Object is also a special data type. To create an object variable, use the new keyword. For details, please see: PHP object type (object)
Finally, there are two special types:
7) resource (resource): The source is a special variable that saves a reference to an external resource. Resources are created and used through specialized functions. For details, please see: PHP resource type (resource)
8) NULL (NULL): Indicates that a variable has no value. The only possible value of the NULL type is NULL

10.PHP version difference

PHP5.2 Before: autoload, PDO and MySQLi, type constraints, JSON support
PHP5.3 : Deprecated functionality, anonymous functions, new magic methods, namespaces, late static binding of Heredoc and Nowdoc, const, ternary operator, Phar
PHP5.4: Short Open Tag, array abbreviation, Traits, Built-in web server, details modified
PHP5.5: yield, list() is used for foreach, details modified
PHP5.6: constant enhancement, variable function parameters, namespace enhancement

11.What is the garbage collection mechanism of PHP?

1) As a scripting language, PHP releases the memory occupied by variables when the page ends.
2) When a PHP thread ends, all memory space currently occupied will be destroyed, and all objects in the current program will be destroyed at the same time.
3) The GC process generally starts running with each SESSION. The purpose of gc is to automatically destroy and delete these files after the session files expire.
4) In PHP, when there is no variable pointing to this object , the object becomes garbage. PHP will destroy it in memory; this is PHP's GC garbage disposal mechanism to prevent memory overflow.
5) Executing these functions can also play a recycling role__destruct /unset/mysql_close /fclose PHP has a clear gc processing time setting for session session.gc_maxlifetime If there is garbage,

6) That is the non-single-piece mode caused by the entire program calling the same file multiple times when using the framework. So when it comes out, use _once reference when necessary, and use singleton mode when declaring the class. There are also simplified logic, etc.

12.PHP features

Features: PHP features include:

1. PHP’s unique syntax mixes C, Java, Perl and PHP's own innovative syntax.
2. PHP can execute dynamic web pages faster than CGI or Perl - in terms of dynamic pages, compared with other programming languages, PHP embeds the program into the HTML document for execution, and the execution efficiency is higher than that of completely generating HTML tags. CGI is much higher;
PHP has very powerful functions, and all CGI functions can be realized by PHP.
3. PHP supports almost all popular databases and operating systems.

4. The most important thing is that PHP can be extended with C and C!

13. Why use php

PHP can run on different platforms (Windows, Linux, Unix, Mac OS X, etc.)
PHP is compatible with almost all platforms currently being used Server compatible (Apache, IIS, etc.)
PHP provides extensive database support
PHP is free and can be downloaded from the official PHP resource: www.php.net
PHP is easy to learn and can Runs efficiently on the server side





##

The above is the detailed content of PHP language. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn