Jump to content

Recommended Posts

HI

This function is to check a site/ip's ping time in ms

 

But it wont work if  i add http:// . It works for google.com but if i add http://google.com it wont work.

 

Here is the function

 

 

 

function ping($host, $port, $timeout) { 
  $tB = microtime(true); 
  $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); 
  $errMsg = 'The Site is Down</p>';
  if (!$fP) { return $errMsg; } 
  $tA = microtime(true); 
  $reSult= round((($tA - $tB) * 1000), 0);
  return $result;
}
 
 
Need help guys :)

 

 

Link to comment
https://forums.phpfreaks.com/topic/277844-function-problem/
Share on other sites

You can use str_replace.For e.g

<?php
echo str_replace("Coder","Developer","Buzzy Coder");
?>

On above code,I had replaced string from "Buzzy Coder" to "Buzzy Developer".I had just changed a word "Coder" to "Developer".You can use below code as an example for your issue.

<?php
echo str_replace("http://","","http://www.google.com");
?>

Add above code to your POST or GET method variable,from which you're getting the user input.

 

Hope it helps you! :happy-04:

Link to comment
https://forums.phpfreaks.com/topic/277844-function-problem/#findComment-1429429
Share on other sites

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.