Jump to content

Function Problem


mssakib

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

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.