What is the php function to use to get the page source of a certain web page?
Thank you very much.
show_source or highlight_file
Try file() or file_get_contents()
HalfaBee
Originally posted by LordShryku show_source or highlight_file
Thanks bro. I already got the page source. Another question, how can I store the string found in the page source? If in perl, every match is stored in the variable $1, $2, and so on, how about in php?
Are there ways of storing the patterns in a variable? for example: preg_match("/I love (.?*)/","I love PHP");
is there a way the I can store the word PHP in a variable since it is the match?
Thanks
$string = preg_match("/I love (.?*)/","I love PHP");
would assign the result of preg_match("/I love (.?*)/","I love PHP"); to the string $string
But it won't return what you want; the [man]preg_match[/man] page will say what it does return, and also how to collect matched text.
PS: Just thought I'd point it out before it causes problems when you try it; it's ".?", not ".?".
Ive tried using ereg in lueue of preg_match. In ereg, it stores the values in the third argument. It also returns the value true or false.
Im also used to pattern things with ".?" rather than ".?". I'll check on it.
Originally posted by fifteen15 Ive tried using ereg in lueue of preg_match. In ereg, it stores the values in the third argument. It also returns the value true or false.
If you read the page I linked to, you'd find that [man]preg_match[/man] does as well.
You will also find that ereg doesn't support the .*? construct.
yup. ive followed your link and it says that ereg an alias of preg_match. I also learned that preg_match supports the pattern matching used in perl like the one you just said, .?. But there is a problem regarding the pattern matching. I don't know if its just because of the .? or .*? or somethings wrong with my program.