Jump to content

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!!!!";
}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.