bonjour

je m'intéresse à Curl en tant qu'alternative à fsockopen

j ai trouvé
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
 
/**
 * Ping an URL
 *
 * @param string $url The URL to ping
 * @return boolean
 */
function ping_url($url) {
 
  $return = true;
 
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
  if (false === curl_exec($ch)) {
    $return = false;
  } elseif (200 !== curl_getinfo($ch, CURLINFO_HTTP_CODE)) {
    $return = false;
  }
 
  curl_close($ch);
  return $return;
}
 
/**
 * Usage example
 */
$messages = array(
    "La page <strong>%s</strong> n'existe pas.<br>",
    "La page <strong>%s</strong> existe.<br>"
);
 
$urls = array(
    'http://www.google.fr/',
    'http://lululululu.net',
    'http://www.dfghhhghgfh.coml',
);
 
foreach ($urls as $url) {
  printf($messages[(int) ping_url($url)], $url);
}
le problème est que ça me répnd que le domaine existe même pour http://lululululu.net qui n est pas un domaine valide - ( code 200)

je voulais l'utiliser pour mon annuaire de lien, mais du coup cela ne me parait pas adapté - est ce que quelquechose m'échappe?

merci pour votre aide