I've got cURL set up to return the result of a http request as a string:
$curl = curl_init($URL); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $Page = curl_exec($curl); if(curl_errno($curl)) die( 'cURL Error: ' . curl_error($curl) ); // Is it bad the curl_close is not getting called? Am I leaking memory? curl_close($curl);
I'm trying to search $Page to find the "<title>" tag so I can modify it. So naturally, I do this:
$title_pos = stripos($Page, "<title>"); if($title_pos === false) echo "stripos failed.\n";
My code always prints "stripos failed" when I pass the $Page variable to it. I'm pretty sure the $Page variable is a valid string because when I echo it, it prints out the whole web page.
I'm also sure that $Page contains a <title> tag. I've even tried making it search for the first occurrence of "a" and it still fails. This makes me think that there is a problem with the $Page string. When I declare a string and fill it with random characters and do a similar stripos on it, it works. Could there be anything inside $Page that makes this funciton fail?
I appreciate your time.