0

I am using preg_match function in my program. The code is like this

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

But run the application it shows the warning like this

Warning: preg_match() [function.preg-match]: No ending delimiter '^' 

Can you help me please..

Nicolas Racine
  • 1,031
  • 3
  • 13
  • 35

1 Answers1

0

You must add pattern delimiters:

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

Since you have forgotten to put delimiters in your pattern, the regex engine believes that ^ is the starting delimiter and is surprised to not found the same delimiter at the end of the pattern.

Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125