Salve,
Ho un problema con l'ottenere il contenuto di una pagina html.
La pagina in questione è così composta:
codice HTML:
<html>
<head></head>
</body>error</body>
</html>
e si chiama testerror.html
Questo è invece lo script PHP incriminato che non ne vuole sapere di funzionare:
Codice PHP:
<?php
$ch = curl_init('http://domain.com/testerror.html');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$text = curl_exec($ch);
preg_match('~<body[^>]*>(.*?)</body>~si', $text, $body);
echo $body[1];
?>
Se stampo $text mi da come output "errore" come giusto che sia.
Se stampo $body[1] mi da output vuoto, perchè?
EDIT:
Mi sono accorto che in realtà la pagina che vado a richiedere è così composta:
"errore"
praticamente non ha tag html, come faccio a fare un controllo su quella stringa?
Grazie in anticipo!