M
M
Maxim2020-04-17 10:51:12
PHP
Maxim, 2020-04-17 10:51:12

How to compare a link with a benchmark?

Good afternoon.
There are two variables: one is the link specified by default on the server.
The second is the link received from the post request.
How can I compare them (do I need the domain name to match)?

$a = $_POST['link'];
$b = 'domain.com';

I understand that you need to parse the link in a via preg_replace, but I don't understand how to do it to leave only the domain.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kafkiansky, 2020-04-17
@ikfah012

$url = 'https://google.com';

var_dump(parse_url($url, PHP_URL_HOST));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question