Last active
February 16, 2016 13:56
-
-
Save pdechery/b4af7f76eaa6c15cb72a to your computer and use it in GitHub Desktop.
Pegadinhas PHP
This file contains 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 | |
// func_get_args() | |
function foo() { | |
$arg = func_get_args(); | |
echo $arg[0]; | |
} | |
foo('I\'m singin in the rain...'); | |
echo "\n"; | |
// double quotation | |
$var = 'foo'; | |
echo "A variável \$var possui o valor $var"; | |
echo "\n"; | |
// strip_tags() | |
$html = "<p><a href=\"#\">Conteúdo</a><span>Bla bla bla</span></p>"; | |
echo strip_tags($html, '<span>'); | |
echo "\n"; | |
// global var | |
$test = 10; | |
function bar() { | |
global $test; | |
$test = 4; | |
} | |
bar(); | |
echo $test; | |
echo "\n"; | |
// echo com {} | |
echo "O mar é azul e cheio de {$var}'s"; | |
echo "\n"; | |
// funcoes e parametros | |
function qualRango($par1, $par2, $par3) { | |
echo "Vou comer $par1 e $par2"; | |
} | |
echo qualRango('arroz','feijão'); // Missing argument 3 for qualRango() | |
echo "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment