This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$input = 'Raphael'; | |
if(!empty($input)){ | |
echo $input; | |
}else{ | |
echo 'Vazio' . "\n\r"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$input = 'Raphael'; | |
if(!empty($input)){ | |
echo $input; | |
}else{ | |
echo 'Vazio' . "\n\r"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$em->transactional(function($em){ | |
//... | |
$em->persist($user); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$em->getConnection()->beginTransaction(); | |
try{ | |
//... | |
$em->persist($user); | |
$em->flush(); | |
$em->getConnection()->commit(); | |
}catch(Exception $e){ | |
$em->getConnection()->rollback(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cores = array( | |
array('cor' => 'verde'), | |
array('cor' => 'vermelho'), | |
array('cor' => 'amarelo') | |
); | |
usort($cores, function($a, $b){ | |
return strcmp($a['cor'], $b['cor']); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function(){ | |
echo 'Olá'; | |
} | |
$saudacao = function(){ | |
echo 'Olá'; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
trait SomeClass{ | |
public function add($x, $y) { return $x + $y; } | |
} | |
class TestComponent { | |
use SomeClass; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class TestComponent { } | |
class SomeClass extends CBehavior{ | |
public function add($x, $y) { return $x + $y; } | |
} | |
$test_comp = new TestComponent(); | |
$test_comp->attachbehavior('blah', new SomeClass); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Service\User{ | |
public function getUser(){ | |
return ['id' => 1, | |
'name' => 'Raphael Almeida', | |
'publisher' => true]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//array vazio | |
$lista = []; | |
//array | |
$lista = ['Raphael', 'Gabriela', 'Eduarda']; | |
//array multi-dimensional |