Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP: The good, the bad and the ugly

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

PHP: The good, the bad and the ugly

Avatar for Giuseppe Capizzi

Giuseppe Capizzi

December 17, 2012

More Decks by Giuseppe Capizzi

Other Decks in Programming

Transcript

  1. Type hinting function foo(string $s) {} foo("hello world"); // PHP

    Catchable fatal error: Argument 1 passed to foo() must be an instance of string, string given
  2. empty() “ A variable is considered empty if it does

    not exist or if its value equals FALSE” $var = ""; empty($var); // true, because "" == false
  3. if (strpos("hello, world!", "hello")) { echo "found!"; } else {

    echo "not found :("; } // not found :( array_search, strpos
  4. Conclusions ★ If you can, don’t use it! ★ If

    you have to: • know your enemy :) • take advantage of the new goodness