检测特殊字符PHP

I am trying to check whether a string contains any special chars so I know what to do with it afterwards in my script.

Heres what I have:

if (preg_match('/[^A-Z0-9_@£\$¥èéùìòÇØø\+%&\!"#'\(\)\*,\-\.Å寿ߤ:;<=>?¡ÄÖÑܧ¿äöñüà€ΓΔΘΛΞΠΣΦΨΩαβγδεζηθικλμνξοπρστυφχψωςέάόίώύήϊϋΐΰΆΈΊΉΌΎΏXΥΡΟΝΜΚΗΖΕΙΤΑΧΒ\^\{\}\\\[~\]\|\/ 
]/',$message)) {}

However I get the following error syntax error, unexpected T_NS_SEPARATOR.

You forgot some escapes:

if (preg_match('/[^A-Z0-9_@£\$¥èéùìòÇØø\+%&\!"#'\(\)\*,
               ^-start string                  ^---end string

Since that's a '-quoted string for the pattern as a whole, all ' inside the pattern MUST be escaped.

You could compare all alphanumeric characters against the string to check if there is any special character:

$temp = '$tack0verflow_';

if(strlen($temp) == strlen(preg_replace("/[^a-zA-Z0-9]+/", "", $temp))){
    // No special characters
} else {
    // Has special characters
}