Jump to content

Dont know what its called


Russia

Recommended Posts

I am trying to find out what this is called.

 

Its like when you get a webpages contents, and if certain words that you are looking for are found then it will say something, if the words you are looking for are not found, then say something else.

 

What is that called? I think curl is used for it.

 

Example:

 

 

if (preg_match("/User is Online./i", $pagedata))
{
echo = "user is online";
    }
else (preg_match("/User is Offline./i", $pagedata)) 
{
echo = "user is offline";
} 

 

I have no idea what its called or how to do it.

Link to comment
https://forums.phpfreaks.com/topic/184469-dont-know-what-its-called/
Share on other sites

So something like this?

 

<?php
$pagedata = file_get_contents("http://example.com/profile/user_bucket.php");
if (preg_match("/User is Online./i", $pagedata))
{
echo = "user is online";
    }
else (preg_match("/User is Offline./i", $pagedata)) 
{
echo = "user is offline";
} 
?>

 

So basically if the user named Bucket is online on his profile and it looks for the word "online" or "offline" it will come back and tell me if he is?

file_get_contents grabs the page/file that is the argument, and converts the entire page to a string which is in your case: $pagedata

 

you can then run a regex against that variable ($pagedata) to check for matches of anything that might be on/in that page/string($pagedata).

 

what regex is run is up to you since nobody here knows what will be available within $pagedata.

Something like?

$handle = fopen("http://www.example.com/", "rb");
$data = stream_get_contents($handle);
fclose($handle);

$find = "Find me";

$pos = strpos($data, $find);
if ($pos === 0)
{
    // Not found...
    echo "Not found...";
} else {
    // Found!
    echo "Found!!!!";
}

 

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.