www.91084.com

GVKun编程网logo

一起看看 PHP Javascript 语法对照(php,javascript)

1

在本文中,我们将给您介绍关于一起看看PHPJavascript语法对照的详细内容,并且为您解答php,javascript的相关问题,此外,我们还将为您提供关于5、PHP-将浮点数转为整数php浮点数

在本文中,我们将给您介绍关于一起看看 PHP Javascript 语法对照的详细内容,并且为您解答php,javascript的相关问题,此外,我们还将为您提供关于5、PHP-将浮点数转为整数 php 浮点数比较 php 浮点数精度 php 浮点数格式、Ajax + php 不工作,php 工作但 javascript 不工作、JavaScript 以一种聪明的方式创建带有子数组的对象/数组/在 JavaScript 中复制 PHP 数据结构、NGINX 和 PHP-FPM (7.4) 在 ubuntu 404ing 上通过 javascript 访问的 .php 文件的知识。

本文目录一览:

一起看看 PHP Javascript 语法对照(php,javascript)

一起看看 PHP Javascript 语法对照(php,javascript)

一起看看 PHP Javascript 语法对照

相关免费学习推荐:javascript(视频)

PHP、JavaScript 语法对照、速查

2c3956e5ffa1451c3f612540e8411fa.png

全栈工程师看过来,学的计算机语言多了,往往会把不同语言的各个函数搞混。作为一个全栈PHPer,往往PHP、JavaScript 语法傻傻分不清楚,百度一下,查手册要网速。不如收藏下这篇文章,打印出来,贴到一旁快速查阅。

JavaScript 的一些数组map函数有jQuery实现,ES6后,又出了官方实现。PHP 的数组、字符串相关函数的命名随性,这仨一块就更容易混淆了。

编码风格

立即学习“PHP免费学习笔记(深入)”;

语言 PHP JavaScript
换行 ; 号 换行符号是必须的 换行 \n,以及 ; 号都不是必须的
大小写敏感度 只有变量名区分大小写 变量名、函数名、类名等 都区分大小写
严格模式 declare(strict_types=1); (PHP7新特性) "use strict";(ECMAScript 5 引入)

变量声明

语言 PHP JavaScript
常量 const VAR_NAME = 12;
define(''VAR_NAME'', 12);
const MY_FAV = 7; (ES6引入的标准)
局部变量 $varName = 12; (PHP严格的来讲,只有函数作用域,或者全局作用域) function myFunc() {
   var varName = 3;
if (true) {
let varName2 = 2;
}
}
(函数作用域内必须用var声明,否则变量全局可访问.)
(let修饰的变量就是块级别作用域,ES6引入)
全局变量 $varName = 12;
function myFunc() {
global $varName;
}
(函数内使用全局变量,必须要用global变量声明使用外部的全局变量)
var varName1 = 3;
varName2 = 2;
function myFunc() {
varName3 = 6;
} (这里写法varName1,2,3都是全局变量)
全局符号表 $GLOBALS  数组 window 对象
为定义变量 null undefined

变量转换

语言 PHP JavaScript
转bool,boolean $bar = (boolean) $foo;  
 $bar = (bool) $foo;
 $bar =  boolval($foo);
boolVal = Boolean('''')
转 int $bar = (int) $foo;
$bar = (integer) $foo;
$bar = intval($foo);
intVal = Number("314")
intVal = parseInt("3.14")
转 float $bar = (float) $foo;
$bar = (double) $foo;
$bar = (real) $foo;
$bar = floatval($foo);
floatVal = Number("3.14")
flotaVal = parseFloat("12")
转换为 string $bar = (string) $foo;
$bar = strval($foo);
str = String(123)
str = (123).toString()
转换为 array $arr = (array) new stdClass(); (需要多行函数完成)
转换为 对象 $obj = (object) array(''1'' => ''foo''); let arr = [''yellow'', ''white'', ''black''];
let obj = {...arr}
时间戳转日期 $date = new DateTime();
$date->setTimestamp(1171502725);
var date = new Date(1398250549490);
字符转日期 $dateObj = new DateTime($dateStr); var myDateObj = new Date(Date.parse(datetimeStr))
转换为 空 (unset) $var; \ 不会删除该变量或 unset 其值。仅是返回 NULL 值而已
获取类型 $varType =  gettype($var); varType = typeof myCar
类判断 $boolRe = $a instanceof MyClass; boolRe = a instanceof MyClass
new Date().constructor === Date

运算符

语言 PHP JavaScript
三目(三元)运算 $a = $a ? $a : 1;//第一种
$a = $a ? : 1;//第二种 PHP5.3支持
re = isMember  ? 2.0 : ''$10.00''
合并运算符 $a = $a ?? 1; //  PHP7支持

数组

语言 PHP JavaScript
基本 $a=array(0 => 1, 1 => 2,4,5,6);
 $array = [ "foo" => "bar", "bar" => "foo"]; // PHP 7语法
b = [1,2,3]
追加 $arr = array();
$arr[key1] = value1;
$arr[key2] = value2;
var mycars=new Array()
mycars[0]="Saab"
mycars[1]="Volvo"
mycars[2]="BMW"
new
var mycars = new Array("Saab","Volvo","BMW")

循环

语言 PHP JavaScript
for 循环 for ($i=1; $i {
echo $i ;
}  
for (var i=0; i {
document.write(cars[i]);
}
foreach ,for in 循环 $x=array("one","two","three");
foreach ($x as $value)
{
echo $value;
}
var person= {fname:"John",lname:"Doe",age:25};
for (x in person)  // x 为属性名
{
txt=txt + person[x];
}
while 循环 while($i {
echo $i ;
$i++;
}
while (i{
x=x + "The number is " + i + "
";
   i++;
}
do while 循环 do {
   $i++;
   echo  $i;
} while ($i
do
{
   document.write(i);
  i++;
}
while (i

本文来自

数组函数

语言 PHP JavaScript
获取数组中元素的数目 count($arr); arrayObject.length
拼接两个字符串 array_merge($arr1, $arr2); arr1.concat(arr2)
删除数组元素 unset($arr[$key]); delete arr1[key]
将数组拼接成字符串 implode('','', $arr1); arr.join(‘,’)
删除并返回数组最后元素 $re = array_pop($arr1); re = arrayObject.pop()
向数组的末尾添加一个元素 array_push($arr1, $var1); len = arrayObject.push(newele1)
将数组的第一个元素删除并返回 $re = array_shift($arr1); re = arrayObject.shift()
向数组的开头添加一个或更多元素 array_unshift($arr1, $var1); len = arrayObject.unshift(newele1)
从已有的数组中返回选定的元素 $newArr = array_splice($arr1,$start,$len); newArr = arrayObject.slice(start,end)
排序 sort($arr1); arrayObject.sort(sortByFunc = null)
颠倒数组中元素的顺序 array_reverse(&$arr, $keepKeys = true); arrayObject.reverse()



each 函数 function map_Spanish($n)
{
   echo $n;
}
$b = array("uno", "dos", "tres", "cuatro", "cinco");
$c = array_map("show_Spanish", $a);
$.each([ 52, 97 ], function( index, value ) {
alert( index + ": " + value );
});
 jQuery 方式
const items = [''item1'', ''item2'', ''item3''];
items.forEach(function(item, index, arr){
 console.log(''key:'' + index + '' value:'' + item);
});
(ES6引入)
回调函数迭代地将数组简化为单一的值 function sum($carry, $item) {
   $carry += $item;
   return $carry;
}
$a = array(1, 2, 3, 4, 5);
var_dump(array_reduce($a, "sum")); // int(15)
var numbers = [65, 44, 12, 4];
function getSum(total, num) {
   return total + num;
}
console.log(numbers.reduce(getSum));
始于ECMAScript 3
用回调函数过滤数组中的单元 function odd($var) {
   // returns whether the input integer is odd
   return($var & 1);
}
$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
echo "Odd :\n";
print_r(array_filter($array1, "odd"));
function isBigEnough(element) {
 return element >= 10;
}
var filtered = [12, 5, 8, 130, 44].filter(isBigEnough); \ JavaScript 1.6 引入

字符

语言 PHP JavaScript
创建 $str = "a string";
\\\\比较特殊的是PHP在双引号字符中可以解析变量
$str2 = ''tow string'';
var carname = "Volvo XC60";
var carname = ''Volvo XC60'';
(同样的在双引号中可以使用转义字符)
多行字符 $bar =    foo
bar
EOT;
var tmpl =''
   !!! 5
   html
     include header
     body
       include script''
字符拼接 $str1 . $str2 str1 + str2

字符串函数

语言 PHP JavaScript
获取字符长度 strlen($str); string.length
获取子字符串 substr ( string $string , int $start [, int $length ] ) : string string.substr(start,length)
str.slice(1,5);
使用一个字符串分割另一个字符串 $pizza  = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
var str="How are you doing today?";
var n=str.split(" ");
\ output:How,are,you,doing,today?
去除字符串首尾处的空白字符(或者其他字符) trim ( string $str [, string $character_mask = " tnr0x0B" ] ) : string
(PHP 函数的可定制要强一点)
var str = " string ";
alert(str.trim());
查找字符串首次出现的位置 $mystring = ''abcsdfdsa'';
$pos = strpos($mystring, ''cs'');
var str="Hello world, welcome to the universe.";
var n=str.indexOf("welcome");
把字符串转换为小写 strtolower ( string $string ) : string string.toLowerCase()
把字符串转换为大写 strtoupper ( string $string ) : string string.toUpperCase()

对象

语言 PHP JavaScript
空对象 $obj = new stdClass(); var obj = new Object();  // 或者
  person={firstname:"John",lastname:"Doe",age:50,eyecolor:"blue"};
对象属性 $obj = new stdClass();
$obj->a = 12;
var myCar = new Object();
myCar.year = 1969; // js还可以以数组形式
myCar["year"] = 1969;
删除属性 unset($obj->a); delete object.property  
delete object[''property'']

正则

语言 PHP JavaScript
创建正则表达式 $pattern = "/.*/i"; var re = /ab+c/;
PCRE 正则 int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags = 0 [, int $offset = 0 ]]] ) var myRe = /d(b+)d/g;
var myRe = new RegExp("d(b+)d", "g");
POSIX 正则 ereg ( string $pattern , string $string [, array &$regs ] ) : int (无)

数学函数

语言 PHP JavaScript
随机函数 $re = mt_rand($min, $max); // 返回 min~max 之间的随机整数 Math.random() // 返回 0 ~ 1 之间的随机数
x的y次方 pow(x,y) Math.pow(x,y)

其他

语言 PHP JavaScript
展开,可变函数 function add(...$numbers) {  
   foreach ($numbers as $n) {  
       $sum += $n;  
   }
}
echo add(1, 2, 3, 4); // PHP5.6 开始支持
function myFunction(x, y, z) { }
var args = [0, 1, 2];
myFunction(...args); (ES6开始支持)
解构 $my_array = array(''a''=>''Dog'',''b''=>''Cat'',''c''=>''Horse'');
list($a, $b, $c) = $my_array;
// php5, 如果是php7版本支持以下语法
[''a''=>$a, ''c''=>$c] = $my_array;
var date1 = [1970, 2, 1];
[ year, mouth ]= date1;
var date2 = {year: 1980, mouth: 3, day: 21};
({ mouth } = date2);
console.log(date1);
console.log(year);
console.log(mouth);

欢迎大家收藏,如果你觉得需要补充的地方,请留言。

以上就是一起看看 PHP Javascript 语法对照的详细内容,更多请关注php中文网其它相关文章!

5、PHP-将浮点数转为整数 php 浮点数比较 php 浮点数精度 php 浮点数格式

5、PHP-将浮点数转为整数 php 浮点数比较 php 浮点数精度 php 浮点数格式

1、使用强制类型转换

首先PHP支持如下所示的数据类型:

<span>1. </span>Integer    (整数)
<span>2. </span>Float      (浮点数)
<span>3. </span>String     (字符串)
<span>4. </span>Boolean    (布尔值)
<span>5. </span>Array      (数组)
<span>6. </span>Object     (对象)
登录后复制

此外还有两个特殊的类型:NULL(空)、resource(资源)。

注:
1. 没有被赋值、已经被重置或者被赋值为特殊值NULL的变量就是NULL类型的变量。
2. 特定的内置函数(例如数据库函数)将返回resource类型的变量。

接着可以使用类似C语言的强制类型转换,例如

<span><?php </span><span>$a</span>=<span>6.66666</span>;
<span>$b</span>=(integer)<span>$a</span>;
<span>echo</span><span>$b</span>;</span>
登录后复制

将输出一个6,直接舍去了小数部分

立即学习“PHP免费学习笔记(深入)”;

2、使用float floor ( float value) 函数

舍去法取整,返回不大于 value 的下一个整数,将 value 的小数部分舍去取整。floor() 返回的类型仍然是 float,因为float 值的范围通常比 integer 要大。

echo <span>floor</span>(<span>4.3</span>);   <span>// 输出4 </span>
echo <span>floor</span>(<span>9.999</span>); <span>// 输出9</span>
登录后复制

3、使用float ceil ( float value) 函数

进一法取整,返回不小于 value 的下一个整数,value 如果有小数部分则进一位。ceil() 返回的类型仍然是 float,因为float 值的范围通常比 integer 要大。

echo <span>ceil</span>(<span>4.3</span>);    <span>// 输出5 </span>
echo <span>ceil</span>(<span>9.999</span>);  <span>// 输出10</span>
登录后复制

4、使用float round ( float val [, int precision])函数

对浮点数进行四舍五入,返回将 val 根据指定精度 precision(十进制小数点后数字的数目)进行四舍五入的结果。precision 也可以是负数或零(默认值)。

echo <span>round</span>(<span>3.4</span>);         <span>// 输出3 </span>
echo <span>round</span>(<span>3.5</span>);         <span>// 输出4 </span>
echo <span>round</span>(<span>3.6</span>);         <span>// 输出4 </span>
echo <span>round</span>(<span>3.6</span>, <span>0</span>);      <span>// 输出4 </span>
echo <span>round</span>(<span>1.95583</span>, <span>2</span>);  <span>// 输出1.96 </span>
echo <span>round</span>(<span>1241757</span>, -<span>3</span>); <span>// 输出1242000 </span>
echo <span>round</span>(<span>5.045</span>, <span>2</span>);    <span>// 输出5.04 </span>
echo <span>round</span>(<span>5.055</span>, <span>2</span>);    <span>// 输出5.06</span>
登录后复制
'').addClass(''pre-numbering'').hide(); $(this).addClass(''has-numbering'').parent().append($numbering); for (i = 1; i '').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了5、PHP-将浮点数转为整数,包括了php,浮点数方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Ajax + php 不工作,php 工作但 javascript 不工作

Ajax + php 不工作,php 工作但 javascript 不工作

如何解决Ajax + php 不工作,php 工作但 javascript 不工作

PHP 代码有效,但 javascript 无效。我无法理解他有什么问题。如何使它工作?链接https://nice-host.com/domain

Javascript 代码

  1. $("#src-btn").click(function() {
  2. var domainname = $(''#domain-name'').val();
  3. $.ajax({
  4. url: "domain-search.PHP",type: ''post'',data: ''Domain ''+domainname,success: function(data)
  5. {
  6. output = ''<div>''+data.text+''</div>'';
  7. $("#result").hide().html(output).slideDown();
  8. }
  9. });
  10. });
  11. $("#domain-search input").keyup(function() {
  12. $("#domain-search input").css(''border-color'','''');
  13. $("#result").slideUp();
  14. });
  1. $domainname = $_POST["domain-name"];
  2. if (isset($_POST["domain-name"])) {
  3. if ( gethostbyname($domainname) != $domainname ) {
  4. echo "<script>alert(''Found'')</script>";
  5. }
  6. else {
  7. echo "<script>alert(''Not found'')</script>";
  8. }
  9. } else {
  10. $output = json_encode(array(''type'' => ''error'',''text'' => ''Empty''));
  11. die($output);
  12. }

HTML 代码

  1. <div id="result"></div>
  2. <form class="domain-search-form parsley-validate" data-animate="fadeInUp" data-delay=".5" method="post" id="domain-search" name="domain-search">
  3. <input type="text" placeholder="Domain name" id="domain-name" name="domain-name" required>
  4. <button class="src-btn" name="src-btn" id="src-btn"><i class="fa fa-search"></i></button>
  5. </form>

解决方法

您的请求没有发送正确的数据,domain-name 是您需要发送的参数名称。

  1. $.ajax({
  2. url: "domain-search.php",type: ''post'',data: {''domain-name'':domainname},success: function(data)
  3. {
  4. output = ''<div>''+data.text+''</div>'';
  5. $("#result").hide().html(output).slideDown();
  6. }
  7. });

JavaScript 以一种聪明的方式创建带有子数组的对象/数组/在 JavaScript 中复制 PHP 数据结构

JavaScript 以一种聪明的方式创建带有子数组的对象/数组/在 JavaScript 中复制 PHP 数据结构

如何解决JavaScript 以一种聪明的方式创建带有子数组的对象/数组/在 JavaScript 中复制 PHP 数据结构

因为我经常使用 PHP,所以我需要一些建议。目前,我正在为我的 UI 开发 HTML/JavaScript AJAX 排序功能。有时一个元素可以有一些孩子 - 有时没有。为了在我的 PHP 后端保存订单,我需要一个 PHP 数据结构,如下所示:

  1. $test = [
  2. ''20'',''22'',''24'' => [
  3. ''25'',''26''
  4. ]
  5. ];
  6. foreach ( $test as $key => $a ) {
  7. if ( is_array( $a ) ) {
  8. error_log(''Key: '' . $key);
  9. error_log( print_r( $a,true ) );
  10. } else {
  11. error_log( $a );
  12. }
  13. }

通过这种方式,我可以检查该值是否是一个数组,以了解它是否有子项,并通过在其他情况下为 null 的键访问父项。

我在 JS 中的唯一方法如下:

  1. let a = {};
  2. let b = 2;
  3. let c = 20;
  4. a[c] = c;
  5. a[b] = b;
  6. let test = [2,3,5];
  7. a[b] = test;
  8. console.log(a);

我对值是键而值有时是数字有时是数组这一事实不太满意。有没有更好的办法来处理这个问题?

解决方法

您的问题不清楚是整体数据结构(即使在 PHP 中)还是在 JavaScript 中复制它的方式有问题。我将假设后者。

您的 JavaScript 代码并不完全等同于 PHP 代码:

  • 在 PHP 中,您在根目录中有一个数组
  • 在 JavaScript 中你有一个对象

我认为实际上您无法在 JavaScript 中拥有相同的数据结构。但是您可以使用 Array.push() 获得更好的等效项,而不必担心密钥。

  1. let a = [];
  2. let b = ''20'';
  3. let c = ''22'';
  4. a.push(c);
  5. a.push(b);
  6. let test = [''25'',''26''];
  7. a.push({''24'': test});
  8. console.log(a);

NGINX 和 PHP-FPM (7.4) 在 ubuntu 404ing 上通过 javascript 访问的 .php 文件

NGINX 和 PHP-FPM (7.4) 在 ubuntu 404ing 上通过 javascript 访问的 .php 文件

如何解决NGINX 和 PHP-FPM (7.4) 在 ubuntu 404ing 上通过 javascript 访问的 .php 文件

当我尝试在 Nginx 提供的网页上通过 ajax 调用运行 register.PHP 时,从上游读取响应标头时,我正在获取未知的主脚本。

即使文件存在于服务器上,也返回 404。我已经尝试了很多不同的方法来解决这个问题 2 天,但无济于事。我已经更改了权限、用户等,但我一直得到相同的结果。

我有一个 .html,其中有一个 .js 使用 ajax POST 到 .PHP,当我这样做时,我收到了那个错误。

这是我的服务器配置:

# Expires map
map $sent_http_content_type $expires {
    default                    off;
    text/html                  epoch;
    text/css                   7d;
    application/javascript     7d;
    ~image/                    7d;
    ~font/                     7d;
}

server {
   listen 80;
   server_name strend.app www.strend.app;

#   expires $expires;

   location / {
      root /usr/share/futuristt_websites/futuristt_websites/strend;
      index index.html index.htm;
      try_files $uri $uri/ =404;
   }

   error_page 500 502 503 504 /50x.html;
   location = /50x.html {
      root html;
   }

   location ~ \\.PHP$ {
      include snippets/fastcgi-PHP.conf;
      fastcgi_pass unix:/run/PHP/PHP7.4-fpm.sock;
   }
}

这是我的 www.conf:

; Start a new pool named ''www''.
; the variable $pool can be used in any directive and will be replaced by the
; pool name (''www'' here)
[www]

; Per pool prefix
; It only applies on the following directives:
; - ''access.log''
; - ''slowlog''
; - ''listen'' (unixsocket)
; - ''chroot''
; - ''chdir''
; - ''PHP_values''
; - ''PHP_admin_values''
; When not set,the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set,the default user''s group
;       will be used.
user = www-data
group = www-data

; The address on which to accept FastCGI requests.
; Valid Syntaxes are:
;   ''ip.add.re.ss:port''    - to listen on a TCP socket to a specific IPv4 address on
;                            a specific port;
;   ''[ip:6:addr:ess]:port'' - to listen on a TCP socket to a specific IPv6 address on
;                            a specific port;
;   ''port''                 - to listen on a TCP socket to all addresses
;                            (IPv6 and IPv4-mapped) on a specific port;
;   ''/path/to/unix/socket'' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /run/PHP/PHP7.4-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 511

; Set permissions for unix socket,if one is used. In Linux,read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0660
listen.owner = www-data
listen.group = www-data

;listen.mode = 0660
; When POSIX Access Control Lists are supported you can set them using
; these options,value is a comma separated list of user/group names.
; When set,listen.owner and listen.group are ignored
;listen.acl_users =
;listen.acl_groups =

; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank,connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1

; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
;       - The pool processes will inherit the master process priority
;         unless it specified otherwise
; Default Value: no set
; process.priority = -19

; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
; or group is differrent than the master process user. It allows to create process
; core dump and ptrace the process for the pool user.
; Default Value: no
; process.dumpable = yes

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives. With this process management,there will be
;             always at least 1 children.
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in ''idle''
;                                    state (waiting to process). If the number
;                                    of ''idle'' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in ''idle''
;                                    state (waiting to process). If the number
;                                    of ''idle'' processes is greater than this
;                                    number then some children will be killed.
;  ondemand - no children are created at startup. Children will be forked when
;             new requests will connect. The following parameter are used:
;             pm.max_children           - the maximum number of children that
;                                         can be alive at the same time.
;             pm.process_idle_timeout   - The number of seconds after which
;                                         an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to ''static'' and the
; maximum number of child processes when pm is set to ''dynamic'' or ''ondemand''.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don''t
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to ''static'',''dynamic'' or ''ondemand''
; Note: This value is mandatory.
pm.max_children = 5

; The number of child processes created on startup.
; Note: Used only when pm is set to ''dynamic''
; Default Value: (min_spare_servers + max_spare_servers) / 2
pm.start_servers = 2

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to ''dynamic''
; Note: Mandatory when pm is set to ''dynamic''
pm.min_spare_servers = 1

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to ''dynamic''
; Note: Mandatory when pm is set to ''dynamic''
pm.max_spare_servers = 3

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to ''ondemand''
; Default Value: 10s
;pm.process_idle_timeout = 10s;

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify ''0''. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
;pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set,no URI will be
; recognized as a status page. It shows the following informations:
;   pool                 - the name of the pool;
;   process manager      - static,dynamic or ondemand;
;   start time           - the date and time FPM has started;
;   start since          - number of seconds since FPM has started;
;   accepted conn        - the number of request accepted by the pool;
;   listen queue         - the number of request in the queue of pending
;                          connections (see backlog in listen(2));
;   max listen queue     - the maximum number of requests in the queue
;                          of pending connections since FPM has started;
;   listen queue len     - the size of the socket queue of pending connections;
;   idle processes       - the number of idle processes;
;   active processes     - the number of active processes;
;   total processes      - the number of idle + active processes;
;   max active processes - the maximum number of active processes since FPM
;                          has started;
;   max children reached - number of times,the process limit has been reached,;                          when pm tries to start more children (works only for
;                          pm ''dynamic'' and ''ondemand'');
; Value are updated in real time.
; Example output:
;   pool:                 www
;   process manager:      static
;   start time:           01/Jul/2011:17:53:49 +0200
;   start since:          62636
;   accepted conn:        190460
;   listen queue:         0
;   max listen queue:     1
;   listen queue len:     42
;   idle processes:       4
;   active processes:     11
;   total processes:      15
;   max active processes: 12
;   max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; ''html'',''xml'' or ''json'' in the query string will return the corresponding
; output Syntax. Example:
;   http://www.foo.bar/status
;   http://www.foo.bar/status?json
;   http://www.foo.bar/status?html
;   http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing ''full'' in the
; query string will also return status for each pool process.
; Example:
;   http://www.foo.bar/status?full
;   http://www.foo.bar/status?json&full
;   http://www.foo.bar/status?html&full
;   http://www.foo.bar/status?xml&full
; The Full status returns for each process:
;   pid                  - the PID of the process;
;   state                - the state of the process (Idle,Running,...);
;   start time           - the date and time the process has started;
;   start since          - the number of seconds since the process has started;
;   requests             - the number of requests the process has served;
;   request duration     - the duration in µs of the requests;
;   request method       - the request method (GET,POST,...);
;   request URI          - the request URI with the query string;
;   content length       - the content length of the request (only with POST);
;   user                 - the user (PHP_AUTH_USER) (or ''-'' if not set);
;   script               - the main script called (or ''-'' if not set);
;   last request cpu     - the %cpu the last request consumed
;                          it''s always 0 if the process is not in Idle state
;                          because cpu calculation is done when the request
;                          processing has terminated;
;   last request memory  - the max amount of memory the last request consumed
;                          it''s always 0 if the process is not in Idle state
;                          because memory calculation is done when the request
;                          processing has terminated;
; If the process is in Idle state,then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
;   ************************
;   pid:                  31330
;   state:                Running
;   start time:           01/Jul/2011:17:53:49 +0200
;   start since:          63087
;   requests:             12808
;   request duration:     1250261
;   request method:       GET
;   request URI:          /test_mem.PHP?N=10000
;   content length:       0
;   user:                 -
;   script:               /home/fat/web/docs/PHP/test_mem.PHP
;   last request cpu:     0.00
;   last request memory:  0
;
; Note: There is a real-time FPM status monitoring sample web page available
;       It''s available in: /usr/share/PHP/7.4/fpm/status.html
;
; Note: The value must start with a leading slash (/). The value can be
;       anything,but it may not be a good idea to use the .PHP extension or it
;       may conflict with a real PHP file.
; Default Value: not set
;pm.status_path = /status

; The ping URI to call the monitoring page of FPM. If this value is not set,no
; URI will be recognized as a ping page. This Could be used to test from outside
; that FPM is alive and responding,or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything,but it may not be a good idea to use the .PHP extension or it
;       may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong

; The access log file
; Default: not set
access.log = /var/log/$pool.access.log

; The access log format.
; The following Syntax is allowed
;  %%: the ''%'' character
;  %C: %cpu used by the request
;      it can accept the following format:
;      - %{user}C for user cpu only
;      - %{system}C for system cpu only
;      - %{total}C  for user + system cpu (default)
;  %d: time taken to serve the request
;      it can accept the following format:
;      - %{seconds}d (default)
;      - %{miliseconds}d
;      - %{mili}d
;      - %{microseconds}d
;      - %{micro}d
;  %e: an environment variable (same as $_ENV or $_SERVER)
;      it must be associated with embraces to specify the name of the env
;      variable. Some exemples:
;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
;  %f: script filename
;  %l: content-length of the request (for POST request only)
;  %m: request method
;  %M: peak of memory allocated by PHP
;      it can accept the following format:
;      - %{bytes}M (default)
;      - %{kilobytes}M
;      - %{kilo}M
;      - %{megabytes}M
;      - %{mega}M
;  %n: pool name
;  %o: output header
;      it must be associated with embraces to specify the name of the header:
;      - %{Content-Type}o
;      - %{X-Powered-By}o
;      - %{Transfert-Encoding}o
;      - ....
;  %p: PID of the child that serviced the request
;  %P: PID of the parent of the child that serviced the request
;  %q: the query string
;  %Q: the ''?'' character if query string exists
;  %r: the request URI (without the query string,see %q and %Q)
;  %r: remote IP address
;  %s: status (response code)
;  %t: server time the request was received
;      it can accept a strftime(3) format:
;      %d/%b/%Y:%H:%M:%s %z (default)
;      The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
;      e.g. for a ISO8601 formatted timestring,use: %{%Y-%m-%dT%H:%M:%s%z}t
;  %T: time the log has been written (the request has finished)
;      it can accept a strftime(3) format:
;      %d/%b/%Y:%H:%M:%s %z (default)
;      The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
;      e.g. for a ISO8601 formatted timestring,use: %{%Y-%m-%dT%H:%M:%s%z}t
;  %u: remote user
;
; Default: "%r - %u %t \\"%m %r\\" %s"
;access.format = "%r - %u %t \\"%m %r%Q%q\\" %s %f %{mili}d %{kilo}M %C%%"

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the ''slowlog'' file. A value of ''0s'' means ''off''.
; Available units: s(econds)(default),m(inutes),h(ours),or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; Depth of slow log stack trace.
; Default Value: 20
;request_slowlog_trace_depth = 20

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the ''max_execution_time'' ini option
; does not stop script execution for some reason. A value of ''0'' means ''off''.
; Available units: s(econds)(default),or d(ays)
; Default Value: 0
;request_terminate_timeout = 0

; The timeout set by ''request_terminate_timeout'' ini option is not engaged after
; application calls ''fastcgi_finish_request'' or when application has finished and
; shutdown functions are being called (registered via register_shutdown_function).
; This option will enable timeout limit to be applied unconditionally
; even in such cases.
; Default Value: no
;request_terminate_timeout_track_finished = no

; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit.
; Possible Values: ''unlimited'' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set,chroot is not used.
; Note: you can prefix with ''$prefix'' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set,the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever
;       possible. However,all PHP paths will be relative to the chroot
;       (error_log,sessions.save_path,...).
; Default Value: not set
;chroot =

; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
;chdir = /var/www

; Redirect worker stdout and stderr into main error log. If not set,stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement,this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes

; Decorate worker output with prefix and suffix containing information about
; the child that writes to the log and if stdout or stderr is used as well as
; log level and time. This options is used only if catch_workers_output is yes.
; Settings to "no" will output data as written to the stdout or stderr.
; Default value: yes
;decorate_workers_output = no

; Clear environment in FPM workers
; Prevents arbitrary environment variables from reaching FPM worker processes
; by clearing the environment in workers before env vars specified in this
; pool configuration are added.
; Setting to "no" will make all environment variables available to PHP code
; via getenv(),$_ENV and $_SERVER.
; Default Value: yes
;clear_env = no

; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .PHP extensions to prevent malicIoUs users to use other extensions to
; execute PHP code.
; Note: set an empty value to allow all extensions.
; Default Value: .PHP
;security.limit_extensions = .PHP .PHP3 .PHP4 .PHP5 .PHP7

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional PHP.ini defines,specific to this pool of workers. These settings
; overwrite the values prevIoUsly defined in the PHP.ini. The directives are the
; same as the PHP SAPI:
;   PHP_value/PHP_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call ''ini_set''.
;   PHP_admin_value/PHP_admin_flag - these directives won''t be overwritten by
;                                     PHP call ''ini_set''
; For PHP_*flag,valid values are on,off,1,true,false,yes or no.

; Defining ''extension'' will load the corresponding shared extension from
; extension_dir. Defining ''disable_functions'' or ''disable_classes'' will not
; overwrite prevIoUsly defined PHP.ini values,but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool,global or /usr)

; Default Value: nothing is defined by default except the values in PHP.ini and
;                specified at startup with the -d argument
;PHP_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;PHP_flag[display_errors] = off
;PHP_admin_value[error_log] = /var/log/fpm-PHP.www.log
;PHP_admin_flag[log_errors] = on
;PHP_admin_value[memory_limit] = 32M

这是我的 fastcgi-PHP.conf:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 512k;
fastcgi_buffers 512 16k;
fastcgi_busy_buffers_size 1m;
fastcgi_temp_file_write_size 4m;
fastcgi_max_temp_file_size 4m;
fastcgi_intercept_errors off;

fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO         $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED   $document_root$fastcgi_path_info;
fastcgi_param QUERY_STRING      $query_string;
fastcgi_param REQUEST_METHOD    $request_method;
fastcgi_param CONTENT_TYPE      $content_type;
fastcgi_param CONTENT_LENGTH    $content_length;
fastcgi_param SCRIPT_NAME       $fastcgi_script_name;
fastcgi_param REQUEST_URI       $request_uri;
fastcgi_param DOCUMENT_URI      $document_uri;
fastcgi_param DOCUMENT_ROOT     $document_root;
fastcgi_param SERVER_PROTOCOL   $server_protocol;
fastcgi_param REQUEST_SCHEME    $scheme;
fastcgi_param HTTPS             $https if_not_empty;
fastcgi_param HTTP_PROXY        "";
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE   Nginx/$Nginx_version;
fastcgi_param REMOTE_ADDR       $remote_addr;
fastcgi_param REMOTE_PORT       $remote_port;
fastcgi_param SERVER_ADDR       $server_addr;
fastcgi_param SERVER_PORT       $server_port;
fastcgi_param SERVER_NAME       $server_name;
fastcgi_param REDIRECT_STATUS   200;

今天的关于一起看看 PHP Javascript 语法对照php,javascript的分享已经结束,谢谢您的关注,如果想了解更多关于5、PHP-将浮点数转为整数 php 浮点数比较 php 浮点数精度 php 浮点数格式、Ajax + php 不工作,php 工作但 javascript 不工作、JavaScript 以一种聪明的方式创建带有子数组的对象/数组/在 JavaScript 中复制 PHP 数据结构、NGINX 和 PHP-FPM (7.4) 在 ubuntu 404ing 上通过 javascript 访问的 .php 文件的相关知识,请在本站进行查询。

本文标签:

上一篇总结 18 个 JavaScript 入门技巧!

下一篇javascript alert是什么意思(javascript中的alert)