- or download this
$encoded = encode_entities($input, '\W');
$encoded = encode_entities($input, '^\w');
- or download this
$encoded = encode_entities($input, '\\W'); # note double backslash
- or download this
$encoded = encode_entities($input, '^a-zA-Z0-9_ ');