Php/docs/function.preg-last-error-msg

提供:Dev Guides
< Php
移動先:案内検索

preg_last_error_msg

(PHP 8)

preg_last_error_msg最後に実行した PCRE 正規表現に関するエラーメッセージを返す


説明

preg_last_error_msg ( ) : string

最後に実行した PCRE 正規表現に関するエラーメッセージを返します。


パラメータ

この関数にはパラメータはありません。


返り値

成功した場合はエラーメッセージを返します。 エラーが起きていない場合は、"No error" を返します。


例1 preg_last_error_msg() example

<?phppreg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');if (preg_last_error() !== PREG_NO_ERROR) {    echo preg_last_error_msg();}?>

上の例の出力は以下となります。


Backtrack limit exhausted

参考