Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ZCPE - PHP Conference 2015

740 views

Published on

A few tricks learned while I was studying to the Zend certification (ZCPE)

Published in: Internet
  • Be the first to comment

ZCPE - PHP Conference 2015

  1. 1. github.com/marabesi twitter.com/MatheusMarabesi
  2. 2. HELP WANTED !
  3. 3. groups/phingbrasil
  4. 4. groups/laravelsp
  5. 5. Who doesn’t want to be certified ?
  6. 6. ????????
  7. 7. $coração = 'Hello'; echo $coração;
  8. 8. class Cächaça { } $cachaça = new Cächaça();
  9. 9. BITWISE
  10. 10. a bitwise operation operates on one or more bit patterns or binary numerals at the level of their individual bits. It is a fast, primitive action directly supported by the processor, and is used to manipulate values for comparisons and calculations
  11. 11. & AND | OR ^ XOR >> RIGHT << LEFT
  12. 12. Bits that are set in both $a AND $b are set. http://php.net/manual/en/language.operators.bitwise.php
  13. 13. & - AND 0 & 0 = 0 0 & 1 = 0 1 & 0 = 0 1 & 1 = 1 print (4 & 8);
  14. 14. Bits that are set in either $a OR $b are set. http://php.net/manual/en/language.operators.bitwise.php
  15. 15. | - OR 0 | 0 = 0 0 | 1 = 1 1 | 0 = 1 1 | 1 = 1 print (2 | 7);
  16. 16. Bits that are set in $a OR $b but not BOTH are set. http://php.net/manual/en/language.operators.bitwise.php
  17. 17. | - XOR 0 ^ 0 = 0 0 ^ 1 = 1 1 ^ 0 = 1 1 ^ 1 = 0 print (3 ^ 9);
  18. 18. 128 64 32 16 8 4 2 1 1 1 1 1 1 1 1 1 255
  19. 19. 128 64 32 16 8 4 2 1 0 0 0 0 0 1 0 0 4 0 0 0 0 1 0 0 0 8 print (4 & 8); & - AND
  20. 20. 128 64 32 16 8 4 2 1 0 0 0 0 0 0 1 0 2 0 0 0 0 0 1 1 1 7 print (2 | 7); | - OR
  21. 21. 128 64 32 16 8 4 2 1 0 0 0 0 0 0 1 1 3 0 0 0 0 1 0 0 1 9 print (3 ^ 9); ^ - XOR
  22. 22. & AND | OR ^ XOR >> RIGHT << LEFT
  23. 23. Shift the bits of $a $b steps to the right (each step means "divide by two") http://php.net/manual/en/language.operators.bitwise.php
  24. 24. bit leftmost / 2 ^ bit rightmost >> - Shift right print (4 >> 6); 4 / 2 ^ 6 = 0
  25. 25. Shift the bits of $a $b steps to the left (each step means "multiply by two") http://php.net/manual/en/language.operators.bitwise.php
  26. 26. bit leftmost * 2 ^ bit rightmost << - Shift left print (7 << 9); 7 * 2 ^ 9 = 3584
  27. 27. Bits that are set in $a are not set, and vice versa. http://php.net/manual/en/language.operators.bitwise.php
  28. 28. ~ - Not ~x = -x -1 print (~9); ~9 = -9 -1 = -10
  29. 29. exit(253); php execute.php
  30. 30. http://www.phpinternalsbook.com/
  31. 31. STREAMS
  32. 32. $context = stream_context_create([ 'http' => [ 'method' => 'GET' ] ]); print file_get_contents( 'http://api.phpconference.com.br', false, $context );
  33. 33. $context = stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/x-www-form-urlencoded', 'content' => 'field=value' ] ]); print file_get_contents( 'http://api.phpconference.com.br', false, $context );
  34. 34. O.O.PObject . Oriented . Programming
  35. 35. LATE STATIC BINDING X SELF
  36. 36. class A { public static function who() { echo __CLASS__; } public static function test() { self::who(); } } class B extends A { public static function who() { echo __CLASS__; } } B::test();
  37. 37. class A { public static function who() { echo __CLASS__; } public static function test() { static::who(); } } class B extends A { public static function who() { echo __CLASS__; } } B::test();
  38. 38. OBJECT CLONING
  39. 39. class A { public $name; } $a = new A(); $b = clone $a; var_dump($a == $b);
  40. 40. class A { public $name; } $a = new A(); $a->name = 'Ana'; $b = clone $a; $b->name = 'Clark'; var_dump($a == $b);
  41. 41. class B { public $lastName; } class A { public $name; public $lastName; public function __construct() { $this->lastName = new B(); } } $a = new A(); $a->lastName->lastName = 'River'; $b = clone $a; $b->lastName->lastName = 'Dom'; var_dump($a == $b);
  42. 42. ARRAY
  43. 43. sort(); rsort(); asort(); ksort(); krsort(); usort();
  44. 44. A K U R ASSOCIATIVE KEY USER REVERSE
  45. 45. sort(); rsort(); asort(); ksort(); krsort(); usort();
  46. 46. array_diff_ukey array_diff_uassoc array_​intersect_​assoc array_​intersect_​uassoc array_​intersect_​ukey
  47. 47. DON’T FORGET !
  48. 48. github.com/marabesi twitter.com/MatheusMarabesi

×