簡體   English   中英

Preg_match的語法

[英]Syntax on Preg_match

我換出了一個已經使用了幾年的程序,並更新了PHP和MySQL的使用權,並且陷入了preg_matchereg語法ereg 我嘗試在所有地方都添加斜杠,但無法提出正確的語法。 我想念什么?

舊線:

if (!$this->config_allow_src_above_docroot
    && !ereg('^'.preg_quote(str_replace($this->osslash, '/', realpath($this->config_document_root))), $AbsoluteFilename))
{

新隊:

if (!$this->config_allow_src_above_docroot
    && !preg_match('^'.preg_quote(str_replace($this->osslash, '/', realpath($this->config_document_root))), $AbsoluteFilename))
{

請原諒,我是否需要轉義'/'?

您缺少preg_*函數所需的定界符:

preg_match('#^'.preg_quote(str_replace($this->osslash, '/', realpath($this->config_document_root))) . '#', $AbsoluteFilename)
            ^                                                                                          ^

當我使用# ,無需轉義正斜杠。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM