Welcome to the Cookbook

loading...

4.2.1 paranoid

There is no translation yet for this section. Please help out and translate this.. More information about translations

paranoid(string $string, array $allowedChars);

This function strips anything out of the target $string that is not a plain-jane alphanumeric character. The function will overlook certain characters by passing them in $allowedChars array.

$badString = ";:<script><html><   // >@@#";
echo Sanitize::paranoid($badString);
// output: scripthtml
echo Sanitize::paranoid($badString, array(' ', '@'));
// output: scripthtml    @@
  1. $badString = ";:<script><html>< // >@@#";
  2. echo Sanitize::paranoid($badString);
  3. // output: scripthtml
  4. echo Sanitize::paranoid($badString, array(' ', '@'));
  5. // output: scripthtml @@