使用cURL时,目标页面是否可以检测到确切的URL?

Lets say we have our own script here:

https://example.com/random_name/script.php

// Code inside the script.php
$url = 'https://foo.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$data = curl_exec($ch);

As you can see, the link above gets content of this domain:

https://foo.com

I know foo.com can see example.com and it's IP Address!

but Questions is, can foo.com (the page we're getting content from) also by any methods detect this exact part: /random_name/script.php is making the request? does it depend on using TLS?

The page (server/application) can have all the information in the request. If the request (in your example - script.php) will not send the extra data (/random_name/script.php) the page the receive the request will not have it.

If you want to receiving end (foo.com) to know about it you can use the referer header:

curl_setopt($ch, CURLOPT_REFERER, "https://example.com/random_name/script.php");

And this way - foo.com can view that information in the referer header.