Re: Searchingfor text within a string
| From: | Patrick Brown | Date: | Wed, 30 Aug 2000 04:14:23 +0000 |
| Subject: | Re: Searchingfor text within a string | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14309@lists.php.net to get a copy of this message | ||
You are absolutely right, sorry for doubting you. I rewrote the code and it
looks like this:
<?
passthru("ping -c 1 $address", $result);
if ($result == 0){
echo "Green Light\n";
} else {
echo "Red Light\n";
}
?>
I created a simple form that passes the $address variable to this script.
The results were a bit weird, The output of the ping command is also
displayed in the browser. How can I get rid of this? If you replace the
$address variable above with a valid, or invalid, address it works great. I
only get the weird output when I use the form.
Thanks for your help,
Pat
"Robin Vickery" <robin@planet-three.co.uk> wrote in message
news:kspumsnjnf.fsf@Robin.planet...
> pbrown@sla.com ("Patrick Brown") writes:
>
> > I just tried that with no success. I always get "Green Light". Here's
the
> > code I used:
> >
> > <?
> > passthru('ping -c 1 1.1.1.1', $string);
> > echo $string;
> > echo "<br>\n";
> > if(strstr($string,"100%")){
> > echo "Red Light<br>\n";
> > } else {
> > echo "Green Light<br>\n";
> > }
> > ?>
>
> OK, passthru doesn't put the output of ping in $string, it puts the
> return value of ping in it, ie. false if there were no errors
> and true if something went wrong.
>
> If you want the actual output of ping, try using backticks like so:
>
> $string =
ping -c 1 127.0.0.1;
>
> -robin
>
> --
> Robin Vickery...............................................
> Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK
> Email: robin@planet-three.net Phone: +44 (0)870 729 5444
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>