Jump to content

[SOLVED] Find string in page


tcpalmer

Recommended Posts

I am getting:

Parse error: parse error, unexpected T_STRING in /home/content/t/c/p/tcpalmer/html/test.php on line 3

 

Note I changed the find string to what I will actually be searching for on a different page.

 

<?php
$html = file_get_contents("http://xkcd.com/663/");
$find = "<TD CLASS="dddefault">0</TD>";
if(stripos($html,$find) !== false){
   echo "found";
}

 

I think it is because of the other quotation marks in the string I am searching for.

 

The syntax highlighting of the forum shows up your problem. You are trying to use a double quotes in a string that is delimited (started and ended) with a double quote. You will need to either escape them or change the delimiters to single quotes....

 

$find = "<TD CLASS=\"dddefault\">0</TD>";
// or
$find = '<TD CLASS="dddefault">0</TD>';

Thank you guys both for your help so far.

 

Earlier the function stripos worked, now it doesn't so I replaced it with strpos.

 

Earlier file_get_contents for the https page, but now that is not working either.  You do not have to be logged into anything to access this https page.

 

Any ideas?  I checked with my hosting provider and they didn't do anything.  I am running PHP version 4.x

Well it was announced late 2005, and yet theirs no release date (that i know of)

a few things to keep in-mind, when developing (don't rely on magic_quotes or register_globals and update ereg's to preg's

here is a list of changes in PHP6

  • magic_quotes, register_globals, register_long_arrays,safe_mode are all removed YAY
  • removed ereg (update to preg people)
  • Improved Unicode support
  • Namespaces (well that's now in 5.30)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.