php :
In the first example, the variable $arr takes the result of the function array_filter . In this case, it does not represent a function. $arr will be assigned to the filtered array. Call it assignment :
$arr = array_filter(explode(' ', trim($str)), function($v) { return mb_strlen($v) > 1; });
And it doesn't make any sense at all:
$a = if($b = 0) { //ΠΏΡΠΈΡΠ²Π°ΠΈΠ²Π°Π΅ΠΌ $a = 0 return 0; } else { //ΠΏΡΠΈΡΠ²Π°ΠΈΠ²Π°Π΅ΠΌ $a = 1 return 1; }
The assignment through the ternary operator looks like this:
$a = ($b == 0) ? 0 : 1; // ΡΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ $b ΠΈ ΠΏΡΠΈΡΠ²Π°ΠΈΠ²Π°Π½ΠΈΠ΅ $a // $a = 0 $a = ($b = 0) ? 0 : 1; // ΠΏΡΠΈΡΠ²Π°ΠΈΠ²Π°Π½ΠΈΠ΅ $b,ΡΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΡΠΈΡΠ²Π°ΠΈΠ²Π°Π½ΠΈΠ΅ $a // $a = 1
If we talk about " ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡ, ΠΊΠΎΠ³Π΄Π° Π½Π΅ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²Π΅Π½Π½ΠΎ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½Π°Ρ ΠΈΠ³ΡΠ°Π΅Ρ ΡΠΎΠ»Ρ ΡΡΠ½ΠΊΡΠΈΠΈ ", this is called a function variable :
function foo(int $param) { return $param + 1; } $foo = 'foo'; // ΡΠ΅ΠΏΠ΅ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½Π°Ρ $foo Π²ΡΠ·ΠΎΠ²Π΅Ρ ΡΡΠ½ΠΊΡΠΈΡ foo() echo $foo(1); // 2
Also in the language there are anonymous functions :
$a = function(int $param) { return $param + 1; }; var_dump($a(1)); // int(2)
javascriptlabel is superfluous here) - Stepan Kasyanenkoarray_filerfunction. and the third filtering parameter is an anonymous function. - teran