文字列のエンコーディングを取得するには、mb_detect_encoding()関数を使用します。

<?php
echo mb_detect_encoding('test').'\n';
echo mb_detect_encoding('てすと').'\n';
?>

◆実行結果
ASCII
UTF-8

[対象]
PHP 5.x