github.com/marabesi
twitter.com/MatheusMarabesi
HELP
WANTED !
groups/phingbrasil
groups/laravelsp
Who doesn’t want to be certified ?
????????
$coração = 'Hello';
echo $coração;
class Cächaça{}
$cachaça = new Cächaça();
BITWISE
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
& AND
| OR
^ XOR
>> RIGHT
<< LEFT
Bits that are set in
both $a AND $b are set.
http://php.net/manual/en/language.operators.bitwise.php
& - AND
0 & 0 = 00 & 1 = 01 & 0 = 01 & 1 = 1
print (4 & 8);
Bits that are set in
either $a OR $b are set.
http://php.net/manual/en/language.operators.bitwise.php
| - OR
0 | 0 = 00 | 1 = 11 | 0 = 11 | 1 = 1
print (2 | 7);
Bits that are set in
$a OR $b but not
BOTH are set. http://php.net/manual/en/language.operators.bitwise.php
| - XOR
0 ^ 0 = 00 ^ 1 = 11 ^ 0 = 11 ^ 1 = 0
print (3 ^ 9);
128 64 32 16 8 4 2 11 1 1 1 1 1 1 1 255
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
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
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
& AND
| OR
^ XOR
>> RIGHT
<< LEFT
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
bit leftmost / 2 ^ bit rightmost
>> - Shift right
print (4 >> 6);
4 / 2 ^ 6 = 0
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
bit leftmost * 2 ^ bit rightmost
<< - Shift left
print (7 << 9);
7 * 2 ^ 9 = 3584
Bits that are set in $a are not set, and vice versa.
http://php.net/manual/en/language.operators.bitwise.php
~ - Not
~x = -x -1
print (~9);
~9 = -9 -1 = -10
exit(253);
php execute.php
http://www.phpinternalsbook.com/
STREAMS
$context = stream_context_create([ 'http' => [ 'method' => 'GET' ]]);
print file_get_contents('http://api.phpconference.com.br',false,$context
);
$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
);
O.O.PObject . Oriented . Programming
LATE STATIC BINDING
XSELF
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();
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();
OBJECT CLONING
class A { public $name;}
$a = new A();
$b = clone $a;
var_dump($a == $b);
class A { public $name;}
$a = new A();$a->name = 'Ana';
$b = clone $a;$b->name = 'Clark';
var_dump($a == $b);
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);
ARRAY
sort();rsort();asort();ksort();krsort();usort();
A
K
U
R
ASSOCIATIVE
KEY
USER
REVERSE
sort();rsort();asort();ksort();krsort();usort();
array_diff_ukeyarray_diff_uassocarray_intersect_assocarray_intersect_uassocarray_intersect_ukey
DON’T
FORGET !
github.com/marabesi
twitter.com/MatheusMarabesi