检测URL是否等于值并执行操作

I want to make action if the current url only equals to this: https://www.example.co.il/index.php?id=1000&2222

$url = 'https://www.example.co.il/index.php?id=1000';
        if(strpos($url,'&2222')) 
          {
        // Do something 
           echo "2222";
        }
        else
        {
        // Do Nothing
        }

To exactly do what you are asked, try this

 //actual link (http or https)
$actualUrl = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url        = 'https://www.example.co.il/index.php?id=1000';
if($actualUrl === $url) {
    //do something
}

But if you just want to retrieve the id :

$id = $_GET('id');
//return 1000 in your case

You're able to read the parameters in the URL using the $_GET object. It lists the keys and values in the querystring, i.e. in your example,

https://www.example.co.il/index.php?id=1000

if you use:

print $_GET['id'];

you'll see 100.

so you could simply check for the existence of the key 2222:

if (isset($_GET['2222'])) { /** do something **/ }

bear in mind, this is only the case if you're actually reading a URL the script is running on.

your method of searching for a string within the URL is appropriate if you simply want to match a value in a string, whether its a URL or not.

USE THIS

// Assign your parameters here for restricted access
$valid_url = new stdClass();
$valid_url->scheme = 'https';
$valid_url->host = 'www.example.co.il';  
$valid_url->ids  = array(1000,2222);

$url = 'https://www.example.co.il/index.php?id=1000&2222';         
$urlinfo = parse_url($url); // pass url here
$ids = [];
parse_str(str_replace('&', '&id1=', $urlinfo['query']), $ids);

if($urlinfo['scheme'] == $valid_url->scheme && $urlinfo['host'] == $valid_url->host && count(array_intersect($valid_url->ids, $ids)) == count($valid_url->ids)){
    echo 'valid';
    // Do something 
}else{
    echo 'in valid';
    // error page
}