T
T
toropchin2015-04-15 09:08:33
PHP
toropchin, 2015-04-15 09:08:33

How to make PhpStorm not swear at escaping slashes in regular expressions?

PhpStorm complains about escaping slashes in regular expressions.
b4487c7d449c49a6b515da2e6a56d9bb.png

preg_match("/$_SERVER[HTTP_HOST]\/.*\//", $_SERVER['SCRIPT_FILENAME'], $result

Can this be fixed somehow?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey, 2015-04-15
@toropchin

He just says that you wrote garbage.
Who will escape the variable with preg_quote? Who will learn what double quotes mean in php, and what will be the regular expression as a result? If it's not you, then do it

preg_match("/$_SERVER[HTTP_HOST]\\/.*\\//", $_SERVER['SCRIPT_FILENAME'], $result);

O
OnYourLips, 2015-04-15
@OnYourLips

I can advise you to update PhpStorm: everything is fine with me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question