zcpe - php conference 2015

67

Upload: matheus-marabesi

Post on 10-Jan-2017

563 views

Category:

Internet


0 download

TRANSCRIPT

Page 1: ZCPE   - PHP Conference 2015
Page 2: ZCPE   - PHP Conference 2015

github.com/marabesi

twitter.com/MatheusMarabesi

Page 3: ZCPE   - PHP Conference 2015
Page 4: ZCPE   - PHP Conference 2015
Page 5: ZCPE   - PHP Conference 2015

HELP

WANTED !

Page 6: ZCPE   - PHP Conference 2015
Page 7: ZCPE   - PHP Conference 2015
Page 8: ZCPE   - PHP Conference 2015

groups/phingbrasil

Page 9: ZCPE   - PHP Conference 2015
Page 10: ZCPE   - PHP Conference 2015

groups/laravelsp

Page 11: ZCPE   - PHP Conference 2015

Who doesn’t want to be certified ?

Page 12: ZCPE   - PHP Conference 2015
Page 13: ZCPE   - PHP Conference 2015
Page 14: ZCPE   - PHP Conference 2015

????????

Page 15: ZCPE   - PHP Conference 2015
Page 16: ZCPE   - PHP Conference 2015
Page 17: ZCPE   - PHP Conference 2015
Page 18: ZCPE   - PHP Conference 2015
Page 19: ZCPE   - PHP Conference 2015

$coração = 'Hello';

echo $coração;

Page 20: ZCPE   - PHP Conference 2015
Page 21: ZCPE   - PHP Conference 2015

class Cächaça{}

$cachaça = new Cächaça();

Page 22: ZCPE   - PHP Conference 2015

BITWISE

Page 23: ZCPE   - PHP Conference 2015
Page 24: ZCPE   - PHP Conference 2015

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

Page 25: ZCPE   - PHP Conference 2015

& AND

| OR

^ XOR

>> RIGHT

<< LEFT

Page 26: ZCPE   - PHP Conference 2015

Bits that are set in

both $a AND $b are set.

http://php.net/manual/en/language.operators.bitwise.php

Page 27: ZCPE   - PHP Conference 2015

& - AND

0 & 0 = 00 & 1 = 01 & 0 = 01 & 1 = 1

print (4 & 8);

Page 28: ZCPE   - PHP Conference 2015

Bits that are set in

either $a OR $b are set.

http://php.net/manual/en/language.operators.bitwise.php

Page 29: ZCPE   - PHP Conference 2015

| - OR

0 | 0 = 00 | 1 = 11 | 0 = 11 | 1 = 1

print (2 | 7);

Page 30: ZCPE   - PHP Conference 2015

Bits that are set in

$a OR $b but not

BOTH are set. http://php.net/manual/en/language.operators.bitwise.php

Page 31: ZCPE   - PHP Conference 2015

| - XOR

0 ^ 0 = 00 ^ 1 = 11 ^ 0 = 11 ^ 1 = 0

print (3 ^ 9);

Page 32: ZCPE   - PHP Conference 2015
Page 33: ZCPE   - PHP Conference 2015

128 64 32 16 8 4 2 11 1 1 1 1 1 1 1 255

Page 34: ZCPE   - PHP Conference 2015

128 64 32 16 8 4 2 10 0 0 0 0 1 0 0 40 0 0 0 1 0 0 0 8

print (4 & 8);

& - AND

Page 35: ZCPE   - PHP Conference 2015

128 64 32 16 8 4 2 10 0 0 0 0 0 1 0 20 0 0 0 0 1 1 1 7

print (2 | 7);

| - OR

Page 36: ZCPE   - PHP Conference 2015

128 64 32 16 8 4 2 10 0 0 0 0 0 1 1 30 0 0 0 1 0 0 1 9

print (3 ^ 9);

^ - XOR

Page 37: ZCPE   - PHP Conference 2015

& AND

| OR

^ XOR

>> RIGHT

<< LEFT

Page 38: ZCPE   - PHP Conference 2015

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

Page 39: ZCPE   - PHP Conference 2015

bit leftmost / 2 ^ bit rightmost

>> - Shift right

print (4 >> 6);

4 / 2 ^ 6 = 0

Page 40: ZCPE   - PHP Conference 2015

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

Page 41: ZCPE   - PHP Conference 2015

bit leftmost * 2 ^ bit rightmost

<< - Shift left

print (7 << 9);

7 * 2 ^ 9 = 3584

Page 42: ZCPE   - PHP Conference 2015

Bits that are set in $a are not set, and vice versa.

http://php.net/manual/en/language.operators.bitwise.php

Page 43: ZCPE   - PHP Conference 2015

~ - Not

~x = -x -1

print (~9);

~9 = -9 -1 = -10

Page 44: ZCPE   - PHP Conference 2015

exit(253);

php execute.php

Page 45: ZCPE   - PHP Conference 2015
Page 46: ZCPE   - PHP Conference 2015

http://www.phpinternalsbook.com/

Page 47: ZCPE   - PHP Conference 2015

STREAMS

Page 48: ZCPE   - PHP Conference 2015
Page 49: ZCPE   - PHP Conference 2015

$context = stream_context_create([ 'http' => [ 'method' => 'GET' ]]);

print file_get_contents('http://api.phpconference.com.br',false,$context

);

Page 50: ZCPE   - PHP Conference 2015

$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

);

Page 51: ZCPE   - PHP Conference 2015
Page 52: ZCPE   - PHP Conference 2015

O.O.PObject . Oriented . Programming

Page 53: ZCPE   - PHP Conference 2015

LATE STATIC BINDING

XSELF

Page 54: ZCPE   - PHP Conference 2015

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();

Page 55: ZCPE   - PHP Conference 2015

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();

Page 56: ZCPE   - PHP Conference 2015

OBJECT CLONING

Page 57: ZCPE   - PHP Conference 2015

class A { public $name;}

$a = new A();

$b = clone $a;

var_dump($a == $b);

Page 58: ZCPE   - PHP Conference 2015

class A { public $name;}

$a = new A();$a->name = 'Ana';

$b = clone $a;$b->name = 'Clark';

var_dump($a == $b);

Page 59: ZCPE   - PHP Conference 2015

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);

Page 60: ZCPE   - PHP Conference 2015

ARRAY

Page 61: ZCPE   - PHP Conference 2015

sort();rsort();asort();ksort();krsort();usort();

Page 62: ZCPE   - PHP Conference 2015

A

K

U

R

ASSOCIATIVE

KEY

USER

REVERSE

Page 63: ZCPE   - PHP Conference 2015

sort();rsort();asort();ksort();krsort();usort();

Page 64: ZCPE   - PHP Conference 2015

array_diff_ukeyarray_diff_uassocarray_intersect_assocarray_intersect_uassocarray_intersect_ukey

Page 65: ZCPE   - PHP Conference 2015

DON’T

FORGET !

Page 66: ZCPE   - PHP Conference 2015
Page 67: ZCPE   - PHP Conference 2015

github.com/marabesi

twitter.com/MatheusMarabesi