Skip to content

Instantly share code, notes, and snippets.

@edinella
Created April 18, 2013 22:44
Show Gist options
  • Save edinella/5416824 to your computer and use it in GitHub Desktop.
Save edinella/5416824 to your computer and use it in GitHub Desktop.
<?php
function verificadorDe($tipo){
return function($var) use($tipo) {
return gettype($var) == $tipo;
}
}
$verificaInteiro = verificadorDe('integer');
$verificaTexto = verificadorDe('string');
$ok = $verificaInteiro(1); // true
$ok = $verificaInteiro('1'); // false
$ok = $verificaTexto('abc'); // true
$ok = $verificaTexto(array()); // false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment