Answer the question
In order to leave comments, you need to log in
How to include characters in a regular expression after a get request?
Hello. Such a question
There is a url: site.ru
And there are additions like:
/test/n-nr/ (site.ru/test/n-nr/)
and
/test/ (site.ru/test/)
and
/test/?dn7674 (site.ru/test/?dn7674 )
Exclude the URL in which /n-nr/ goes after test but leave the URL /test/?dn7674
Now I have
$url = $_SERVER["REQUEST_URI"];
$preg = preg_match("/\/test\/./", $url);
How can I leave ?dn7674
It doesn't work
$url = $_SERVER["REQUEST_URI"];
$preg = preg_match("/\/test\/.(^[?/.])/", $url);
Answer the question
In order to leave comments, you need to log in
Why do you need regulars at all?
you have php )
php.net/manual/ru/function.parse-url.php
$url = $_SERVER['REQUEST_URI'] ?? '';
$parse_url = parse_url($url);
if ($parse_url && $parse_url['path'] == 'test') {
// some code
print_r($parse_url['query']);
}
$_GET
$_REQUEST
// и тд
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question