Voting

Please answer this simple SPAM challenge: four plus one?
(Example: nine)

The Note You're Voting On

majkel
2 years ago
During initialization php parses every value as expression. One can declare variables, do calculations, or even manipulate "current" array

<?php

$arr
['A'] = [
    &
$arr, // circular reference
   
'key' => 'val',
   
$arr['B'] = [ // declare array, insert key and then value
       
'a' => 'b',
    ],
   
ucfirst(strtolower('SOME TEXT')),
   
true ? 'TRUE' : 'FALSE', // evaluate expression
   
$x  = 3, // declare variable
   
$x *= 3, // perform calculations
];

var_dump($arr);

// Output
/*
array(2) {
  'B' => array(1) {
    'a' => string(1) "b"
  }
  'A' => array(7) {
    [0] => array(2) {
      'B' => array(1) {
        ...
      }
      'A' => &array
    }
    'key' => string(3) "val"
    [1] => array(1) {
      'a' => string(1) "b"
    }
    [2] => string(9) "Some text"
    [3] => string(4) "TRUE"
    [4] => int(3)
    [5] => int(9)
  }
}
*/
?>

<< Back to user notes page

To Top