Skip to content

Instantly share code, notes, and snippets.

@pdechery
Last active February 16, 2016 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdechery/b4af7f76eaa6c15cb72a to your computer and use it in GitHub Desktop.
Save pdechery/b4af7f76eaa6c15cb72a to your computer and use it in GitHub Desktop.
Pegadinhas PHP
<?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