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

An Introduction to PHP ... And Why It's Yucky!

Jorge Silva
November 13, 2014

An Introduction to PHP ... And Why It's Yucky!

A short introduction to some of the good parts and bad parts of PHP. Mostly the bad parts.

Jorge Silva

November 13, 2014
Tweet

More Decks by Jorge Silva

Other Decks in Technology

Transcript

  1. <?php ?> echo `First, the good parts`; var_dump([ `Web’s most

    popular server lang`, `Incredibly easy to deploy`, `WordPress, uber popular framework`, `Templating is built-in` ]);
  2. <?php ?> echo `Problem #1`; echo `Templating is built-in`; foreach($arr

    as $el) { echo `<p>`; echo doSomeMysteriousThing($el); echo `</p>`; }
  3. <?php ?> echo `Problem #2`; echo `It can be very

    inconsistent`; echo 'hello \nworld'; // hello \nworld echo "hello \nworld"; // hello // world
  4. <?php ?> echo `Problem #3`; echo `Everything is a function!!!`;

    array_push($arr, `abc`); // 5.3 array_key_exists($arr, `abc`); // bool $r = array_merge($arr, [`abc`]); $r = array_map(`func`, $arr); $r = count($arr);
  5. <?php ?> echo `Problem #4`; echo `Equality is unequal`; `6`

    == ` 6` // true `133` == `0133` && 133 != 0133; // true `foo` == 0 && `foo` == true; // true NULL < -1 && NULL == 0; // true
  6. <?php ?> echo `Problem #5`; echo `Scope is weird...`; if

    (1 === 1) { $v = `if`; } function a() { $v = `a`; } function b() { global $v; $v = `b`; } a(); echo $v; // `if` b(); echo $v; // `b`
  7. <?php ?> echo `Problem #6`; echo `Debugging is terrible!`; echo

    $arr; // `Array` print_r($arr); // Array ( [0] => 1 [1] var_dump($arr); // array(4) { [0]=> int( var_dump(debug_backtrace());
  8. <?php ?> echo `In the end...`; echo `...it doesn’t matter

    that much`; $u = `http://blog.codinghorror.com/`; $u .= `php-sucks-but-it-doesnt-matter`; echo $u;