daily pastebin goal
68%
SHARE
TWEET

[PHP]: Verificar se a string tem caracteres inválidos.

garfield Mar 25th, 2012 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.                                 @Função: Verificar se a string tem caracteres inválidos.
  3.                                 @Créditos: [iPs]SuYaNw
  4. */
  5.  
  6. function IsValidString($str)
  7. {
  8.         if(strstr($str, "'") || strstr($str, "!") ||  strstr($str, "@") ||  strstr($str, "#") ||
  9.         strstr($str, "$") ||  strstr($str, "%") ||  strstr($str, "¨") ||  strstr($str, "&") ||
  10.         strstr($str, "*") ||  strstr($str, "(") ||  strstr($str, ")") ||  strstr($str, "-") ||
  11.         strstr($str, "_") ||  strstr($str, "+") ||  strstr($str, "+") ||  strstr($str, "¹") ||
  12.         strstr($str, "²") ||  strstr($str, "³") ||  strstr($str, "ª") || strstr($str, "{") ||
  13.         strstr($str, "[") ||  strstr($str, "]") ||  strstr($str, "}") ||  strstr($str, "º") ||
  14.         strstr($str, "´") ||  strstr($str, "`") ||  strstr($str, "^") ||  strstr($str, "~") ||
  15.         strstr($str, "<") ||  strstr($str, ",") ||  strstr($str, ".") ||  strstr($str, ">") ||
  16.         strstr($str, ":") ||  strstr($str, ";") ||  strstr($str, "/") ||  strstr($str, "°") ||
  17.         strstr($str, "?") ||  strstr($str, "|") || is_numeric($str))
  18.         {
  19.                 return false;
  20.         }
  21.         return true;
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top