My life be like

PHP is weird sometimes

“Every once in a while you you come across something that is so strang…” Published at: 2019-02-20

In PHP when storing an string that could be a valid integer PHP casts it to an int for you. Why?

Example:

    <?php
    $array: [
      "123" => 'php'
    ];

    var_dump($array);

    // Output

    array(1) {
      [123]=>
      string('php')
  }

    // instead of

    array(1) {
      ['123']=>
      string('php')
    }

In javascript the same is possible. I don’t know if this is intended behaviour but for me it feels weird and counterintuitive.

Oscar te Giffel

Oscar te Giffel. I wan't to learn so many things. This is just my journey through life.