Vulpo One




Nobody Takes Power

I regularly recall this quote so let it be here

You’re still laboring under the notion that people take power. Nobody takes power. They’re given power by the rest of us, because we’re stupid or afraid or both. The Germans in 1939. The Russians in 1917 and 2013. The Iraqis in 2025. The French in 2112. They handed over power to people they thought could settle scores. Get the trains running on time. Restore their prestige. They did it because it was what they wanted. Afterwards, like children who have eaten too much candy after dinner they denied it was their fault. It’s always them.

—Babylon 5, s4e16 “Excercise of Vital Powers”, 1997

Comments



PHP 5.6 — variadic func / splat operator

<?php

function func($a, $b, ...$params)
{
   var_dump($a, $b, $params);
}

func(1,2,3,4,5);
// int(1)
// int(2)
// array(3) {
//   [0]=>
//   int(3)
//  [1]=>
//  int(4)
//  [2]=>
//  int(5)
// }
// cool!

$a = [1,2,3,4,5];

func(...$a);
// int(1)
// int(2)
// array(3) {
//   [0]=>
//   int(3)
//  [1]=>
//  int(4)
//  [2]=>
//  int(5)
// }
// even cooler!

$a['qq'] = 'qq';

func(...$a);
// PHP Catchable fatal error:
// Cannot unpack array with string keys in /tmp/test.php on line 16
// okay :(

$b = [];
$b[1] = 1;
$b[4] = 4;
$b[2] = 2;
$b[5] = 5;
$b[3] = 3;

func(...$b);
// int(1)
// int(4)
// array(3) {
//   [0]=>
//   int(2)
//   [1]=>
//   int(5)
//   [2]=>
//   int(3)
// }
// WAT?

Comments