Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public function verificaString($campo)
  2. {
  3. if (isset($_POST[$campo]) && (!empty($_POST[$campo]) && (is_string($_POST[$campo])))):
  4. (string)$var = filter_var(trim($_POST[$campo]), FILTER_SANITIZE_STRING);
  5. return $var;
  6. else:
  7. $var = 'Indisponível';
  8. return $var;
  9. endif;
  10. }
  11.  
  12. empty($var); // true
  13.  
  14. !isset($var) || !$var; // true
  15.  
  16. public function verificaString($campo)
  17. {
  18. if (empty($_POST[$campo]) || !is_string($_POST[$campo]))
  19. {
  20. return 'Indisponível';
  21. }
  22.  
  23. return filter_var(trim($_POST[$campo]), FILTER_SANITIZE_STRING);
  24. }
  25.  
  26. $nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_SPECIAL_CHARS);
  27.  
  28. filter_input(INPUT_POST, $campo, FILTER_SANITIZE_STRING)
  29.  
  30. public function verificaString($campo)
  31. {
  32. return trim(filter_input(INPUT_POST, $campo, FILTER_SANITIZE_STRING)) ?: 'Indisponível';
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement