arguments - Référence — Que signifie ce symbole dans PHP

Mots clés : phpargumentsoperatorssymbolssemanticsphp

meilleur 3 Réponses arguments - Référence — Que signifie ce symbole dans PHP

vote vote

93

Example    Name              Effect --------------------------------------------------------------------- ++$a       Pre-increment     Increments $a by one, then returns $a. $a++       Post-increment    Returns $a, then increments $a by one. --$a       Pre-decrement     Decrements $a by one, then returns $a. $a--       Post-decrement    Returns $a, then decrements $a by one. 
$apples = 10; for ($i = 0; $i < 10; ++$i) {     echo 'I have ' . $apples-- . " apples. I just ate one.\n"; } 
$i = "a"; while ($i < "c") {     echo $i++; } 
vote vote

82

------------------------------------------- |      1 Byte ( 8 bits )                  | ------------------------------------------- |Place Value | 128| 64| 32| 16| 8| 4| 2| 1|      ------------------------------------------- 
$a =  9; $b = 10; echo $a & $b; 
------------------------------------------- |      1 Byte ( 8 bits )                  | ------------------------------------------- |Place Value | 128| 64| 32| 16| 8| 4| 2| 1|      ------------------------------------------- |      $a    |   0|  0|  0|  0| 1| 0| 0| 1|     ------------------------------------------- |      $b    |   0|  0|  0|  0| 1| 0| 1| 0| -------------------------------------------  |      &     |   0|  0|  0|  0| 1| 0| 0| 0| -------------------------------------------  
$a =  36; $b = 103; echo $a & $b; // This would output the number 36. $a = 00100100 $b = 01100111 
$a =  9; $b = 10; echo $a | $b; 
------------------------------------------- |      1 Byte ( 8 bits )                  | ------------------------------------------- |Place Value | 128| 64| 32| 16| 8| 4| 2| 1|      ------------------------------------------- |      $a    |   0|  0|  0|  0| 1| 0| 0| 1|     ------------------------------------------- |      $b    |   0|  0|  0|  0| 1| 0| 1| 0| -------------------------------------------  |      |     |   0|  0|  0|  0| 1| 0| 1| 1| ------------------------------------------- 
vote vote

72

1 <=> 1; // 0 1 <=> 2; // -1 2 <=> 1; // 1 
$arr = [4,2,1,3];  usort($arr, function ($a, $b) {     if ($a < $b) {         return -1;     } elseif ($a > $b) {         return 1;     } else {         return 0;     } }); 
$arr = [4,2,1,3];  usort($arr, function ($a, $b) {     return $a <=> $b;     // return $b <=> $a; // for reversing order }); 

Questions similaires