我应该在这里做什么?



=& 参考

参考任务操作员在PHP, =& 什么意思是“=&”和“&="操作员在PHP? 什么意思是“&=”和“=&”操作员在PHP?

















PHP 中的奇怪打印行为?



= 任命运营商

三种不同的平等


如何区分PHP平等(==双等)和身份(===三等)比较操作员?PHP!=和 ==操作员3个不同的平等类型和(严格)较大的/较小的比较在PHP


=== 比较运营商






比特币运营商


上一篇: 逻辑运营商












[ ] Arrays (自 PHP 5.4 以来简短的合成)


PHP 短标签是否可用?


二角形字符范围




# One-line shell 风格评论


NullSafe Operator 通话(自 PHP 8.0 以来)

PHP 中有“零安全操作员”吗?



当前回答

_ Alias for gettext( )

作为 _() 的字符“_”是 gettext() 函数的标志。

其他回答

PHP Strings: PHP Strings 可以用四种方式定义,而不仅仅是两种方式:

(一)单一引用:

$string = 'This is my string'; // print This is my string

二、双重引用:

$str = 'string';

$string = "This is my $str"; // print This is my string

3、继承人:

$string = <<<EOD
This is my string
EOD; // print This is my string

4) Nowdoc (自 PHP 5.3.0 以来):

$string = <<<'END_OF_STRING'
    This is my string 
END_OF_STRING; // print This is my string

什么是 \ (backslash) 符号在 PHP

它用于逃避字符串类型或更改特定案例:

例子:

在这里使用 \r\n 和 \n 转到新行(如输入按钮)


echo "Hello world \n\r I am Herakl";

否则,您可以使用 PHP_EOL. 有一些例外. 首先,它只能在两个引用(")状态使用。

echo " Hello \\ I am robot";

在 stackoverflow 中,它看不见正确。

Backslashes 也使用在名称空间或使用条件名称:

namespace App\Http\Controllers;

use App\Models;

此外,您还应该参观关于 https://www.php.net/manual/en/function.addslashes.php 的漏洞

Syntax Name Description
x == y Equality true if x and y have the same key/value pairs
x != y Inequality true if x is not equal to y
x === y Identity true if x and y have the same key/value pairs
in the same order and of the same types
x !== y Non-identity true if x is not identical to y
x <=> y Spaceship 0 if x is equal to y, greater than 0 if x > y, less than 0 if x < y
++x Pre-increment Increments x by one, then returns x
x++ Post-increment Returns x, then increments x by one
--x Pre-decrement Decrements x by one, then returns x
x-- Post-decrement Returns x, then decrements x by one
x and y And true if both x and y are true. If x=6, y=3 then
(x < 10 and y > 1) returns true
x && y And true if both x and y are true. If x=6, y=3 then
(x < 10 && y > 1) returns true
x or y Or true if any of x or y are true. If x=6, y=3 then
(x < 10 or y > 10) returns true
x || y Or true if any of x or y are true. If x=6, y=3 then
(x < 3 || y > 1) returns true
a . b Concatenation Concatenate two strings: "Hi" . "Ha"

航天运营商 <=> (添加到 PHP 7)

<=> 航天运营商的例子(PHP 7、来源:PHP手册):

Integers, Floats, Strings, Arrays & Objects for 三路比较变量。

// Integers
echo 10 <=> 10; // 0
echo 10 <=> 20; // -1
echo 20 <=> 10; // 1

// Floats
echo 1.5 <=> 1.5; // 0
echo 1.5 <=> 2.5; // -1
echo 2.5 <=> 1.5; // 1

// Strings
echo "a" <=> "a"; // 0
echo "a" <=> "b"; // -1
echo "b" <=> "a"; // 1
// Comparison is case-sensitive
echo "B" <=> "a"; // -1

echo "a" <=> "aa"; // -1
echo "zz" <=> "aa"; // 1

// Arrays
echo [] <=> []; // 0
echo [1, 2, 3] <=> [1, 2, 3]; // 0
echo [1, 2, 3] <=> []; // 1
echo [1, 2, 3] <=> [1, 2, 1]; // 1
echo [1, 2, 3] <=> [1, 2, 4]; // -1

// Objects
$a = (object) ["a" => "b"]; 
$b = (object) ["a" => "b"]; 
echo $a <=> $b; // 0

$a = (object) ["a" => "b"]; 
$b = (object) ["a" => "c"]; 
echo $a <=> $b; // -1

$a = (object) ["a" => "c"]; 
$b = (object) ["a" => "b"]; 
echo $a <=> $b; // 1

// only values are compared
$a = (object) ["a" => "b"]; 
$b = (object) ["b" => "b"]; 
echo $a <=> $b; // 1

#[] 自 PHP 8 以来的属性

您可以写 #[attribute_name] 从 PHP 8. 这是一个属性在 PHP (也 Rust 和 C#). 其他语言可能使用名称如笔记(Java)或装饰(Python,JavaScript)为类似的功能. 在 PHP 8 之前, # [任何东西] 将是一个评论,直到线的结束(因为 # 开始一个评论在 PHP 。 所以,如果一个属性是线上的最后一件事,它将被忽略在句子中

RFC Syntax RFC(原始 RFC 已更改) 文档