###### some pits.
```
PHPFPM Configuration
Pm.max_children = maximum number of concurrent
A detailed answer:
Pm.max_children represents the maximum number of child processes that PHP-FPM can start.
Because PHP-FPM is a multi-process single-threaded synchronous mode, where a child process processes at most one request at a time, the number of child processes equals the maximum number of concurrent sessions.
However, it is generally not considered in practice, because PHP is configured by default to dynamically balance child process management without manually setting these configurations.
```
```
Log Debugging methods
/**
* Super Debug
*
* Debug non-local environment or distributed environment, through log view variable pass
* Write variable values to \var\log\php_super_debug.log
* @param mixed $data log data
* @param string $log _path log path
* @param string $log _name log Name
* @return void
*/
function Super_debug ($data, $log _path= ' \var\log\ ', $log _name= ' Debug ')
{
Error_log (Json_encode ($data, Json_unescaped_unicode). " \ n ", 3, $log _path. $log _name);
}
```
```
PHP Implementation Download image
Header (' Content-type:image/jpeg ');
Header (' content-disposition:attachment; filename=download_name.jpg ');
ReadFile ($yourFilePath);
```
```
php5.6 started to kill the @ syntax, PHP upload images compatible version of the wording
if (class_exists (' \curlfile ')) {
curl_setopt ($curl, Curlopt_safe_upload, true);
$data = Array (' file ' = = new \curlfile (Realpath ($destination)));//5.5+
} else {
if (defined (' Curlopt_safe_upload ')) {
curl_setopt ($curl, Curlopt_safe_upload, false);
}
$data = Array (' file ' = ' @ '. Realpath ($destination));//<=5.5
}
```
```
Serialization and deserialization
Concept:
Serialization: Convert variables (all types) into variables that can be transferred and stored (without losing the properties and structure of the original variable)
Deserialization: Turning a string into an original variable
Function:
Serialization: Serialize, Json_encode (cannot serialize object)
Deserialization: Unserialize, Json_decode
```
```
Differences in composition and aggregation
Composition: A class produces a reference to Class B during instantiation of an object
Aggregation: Class A in the process of instantiating an object, the class B is not instantiated immediately, but instead waits for an outside object of Class A to pass
```
```
Remember a hole
Ip2long function
-The 32-bit system will turn into a signed int, range -2^31~2^31-1
-64-bit system will be converted to unsigned int, range 0~2^32-1
```
```
The difference between static and self
The first explanation:
-Static: Represents the currently referenced class
-Self: Represents the class in which the current code fragment resides
The second explanation:
If both the subclass and the parent class have a "a" method. So
-Static: A method that will be called to the child class
-Self: Calls to the A method of the current class, if Self::a () in the subclass, will call the A method of the subclass, and if in the parent class, the A method of the parent class will be called.
```
```
Json_encode a pit when used
Json_encode when there is Chinese, need to join Json_unescaped_unicode,json_encode ($data, Json_unescaped_unicode); (PHP version required: must be php5.4+), otherwise the Chinese will be escaped to Unicode encoding.
For example:
$arr = Array (' a ' = = ' Only the owner has read and write rights ', ' B ' + ' = ' owner has read and write permissions, the group user only has Read permission ');
echo Json_encode ($arr);
1. When no json_unescaped_unicode is added, the result is:
{"A": "\u53ea\u6709\u6240\u6709\u8005\u6709\u8bfb\u548c\u5199\u7684\u6743", "B": "\u6240\u6709\u8005\u6709\u8bfb\ U548c\u5199\u7684\u6743\u9650\uff0c\u7ec4\u7528\u6237\u53ea\u6709\u8bfb\u7684\u6743\u9650 "}
2. When Json_unescaped_unicode is added, the result is: {"A": "Only the owner has read and write rights", "B": "The owner has read and write permissions, the group user has only Read permissions"}
```
###### Tips
-Linux
+ df-h: Easier to read view disk space
+ du-h--max-depth=1 file_path: View the space occupied by the folder, display the hierarchy under the--max-depth folder
+ sudo rm-rf \*.log: Cleanup log
+ Socket
* HTTP socket = Ip:port
* UNIX domain Socket:unix process communication interprocess communication
+ ubuntu16.04 installation php5 Source: sudo apt-add-repository ppa:ondrej/php
+ Ubuntu Chinese support: sudo apt-get install language-pack-zh-hant Language-pack-zh-hans
+ Debian cannot start using Lantern: Install dependent apt-get installation Libappindicator3-1
+ View Port occupancy: lsof-i:[port number]/netstat-a (Show all options, default does not show listen) p (show associated program) n (no alias display number) | grep [Port number]
-PHP:
+ Json_encode ($data, Json_unescaped_unicode)
+ PHP Custom header information can be used $_server[' http_* ') to get
+ If you want to know when the script starts executing (that is, the server side receives the client request), use $_server[' request_time '] better than Time ()
+ Error_log (Json_encode ($data, Json_unescaped_unicode), 1/3, ' [email Protected]/log_path ')
+ sudo watch service php5.6-fpm status
+ A good habit after foreach reset pointer position, unset off $key, $value
+ curl_setopt ($ch, Curlopt_ssl_verifypeer, false);
+ laravel [' l?r?,v?l]
+ Language structure in PHP: Echo,exit (), Print,empty (), unset (), Isset (), list (), eval (), Array ()
-Git:
+ git commit--amend rewrite last commit message
+ git cherry-pick counter switch
-Composer:
+ Modify package Source: Sudo composer config repositories. Package name VCs package address
###### PHP Deficiencies
-PHP still has a lot of deficiencies, such as the inability to perform efficient operations
PHPFPM Configuring a Pit in PHP