當我讀到PCRE Pattern Modifiers時,我注意到每個修飾符都有一個我熟悉使用的字符串文字和一個常數,我認爲這是一個明確的選擇。PCRE模式修飾符常量,它們的作用域是否可見?
然而,參照這些常量時,這樣說
echo PCRE_CASELESS === "i";
我得到這個錯誤
PHP Notice: Use of undefined constant PCRE_CASELESS - assumed 'PCRE_CASELESS'
閱讀手冊仔細,我注意到它說
The names in parentheses refer to internal PCRE names for these modifiers
內部是什麼?文件列出它們的事實使我認爲它們在全球範圍內以某種方式可用。
常數「在PHP手冊中應該列出相應的章節,即[* PCRE *]的預定義常量*(http://php.net/pcre.constants)。如果他們沒有列出,他們可能不存在。最後,它們應該包含在'get_defined_constants'的返回值中。 – Gumbo