Jump to content
  • Advertisement
Sign in to follow this  

PHP stripos fails, don't know why..

This topic is 2122 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



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($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$Page = curl_exec($curl);

    die(  'cURL Error: ' . curl_error($curl)  ); // Is it bad the curl_close is not getting called? Am I leaking memory?




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.

Share this post

Link to post
Share on other sites

you're setting it on $ch


The dangers of copy and pasting code from another project.. This makes a lot of weird occurrences suddenly make sense!


Anyway, thanks for spotting my mistake -.-

Edited by Lith

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!