[PHP] object oriented syntax in php

2006-03-28 Thread Merlin

Hi there,

I do have problems with object oriented syntax as this is not familar to me.
There is following output:


object(net_ping_result)(11) { [_icmp_sequence]=  array(1) { [61.117):]= 
string(1) 7 } [_target_ip]=  string(9) y2.php.ne [_bytes_per_request]= 
 string(2) 64 [_bytes_total]=  int(192) [_ttl]=  string(6) _seq=2 
[_raw_data]=  array(7) { [0]=  string(72) PING php.net (66.163.161.117) 
from 192.168.1.114 : 56(84) bytes of data. [1]=  string(72) 64 bytes from 
y2.php.net (66.163.161.117): icmp_seq=1 ttl=47 time=211 ms [2]=  string(72) 
64 bytes from y2.php.net (66.163.161.117): icmp_seq=2 ttl=47 time=206 ms [3]= 
 string(0)  [4]=  string(31) --- php.net ping statistics --- [5]= 
string(55) 2 packets transmitted, 2 received, 0% loss, time 1008ms [6]= 
string(55) rtt min/avg/max/mdev = 206.299/209.139/211.979/2.840 ms } 
[_sysname]=  string(5) linux [_round_trip]=  array(3) { [min]= 
string(7) 209.139 [avg]=  string(7) 211.979 [max]=  string(5) 2.840 
} [_transmitted]=  string(1) 2 [_received]=  string(1) 2 [_loss]= 
int(0) }



Now I would like to retrieve my needed info out of it. How do I do this? (sounds 
a bit silly this question, sorry :-)


I tried:
$ping_result = $ping-ping('php.net');
echo $ping_result[net_ping_result][_raw_data][5];

But this and other tries did not work. My goal is to find out wheter a specified 
site is reachable.


Can anybody give me a hint on this one?

Thank you in advance,

Merlin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] object oriented syntax in php

2006-03-28 Thread Thomas Munz
echo $ping_result[_raw_data][5];

 Hi there,

 I do have problems with object oriented syntax as this is not familar to
 me. There is following output:


 object(net_ping_result)(11) { [_icmp_sequence]=  array(1) {
 [61.117):]= string(1) 7 } [_target_ip]=  string(9) y2.php.ne
 [_bytes_per_request]= string(2) 64 [_bytes_total]=  int(192)
 [_ttl]=  string(6) _seq=2 [_raw_data]=  array(7) { [0]= 
 string(72) PING php.net (66.163.161.117) from 192.168.1.114 : 56(84) bytes
 of data. [1]=  string(72) 64 bytes from y2.php.net (66.163.161.117):
 icmp_seq=1 ttl=47 time=211 ms [2]=  string(72) 64 bytes from y2.php.net
 (66.163.161.117): icmp_seq=2 ttl=47 time=206 ms [3]= string(0)  [4]= 
 string(31) --- php.net ping statistics --- [5]= string(55) 2 packets
 transmitted, 2 received, 0% loss, time 1008ms [6]= string(55) rtt
 min/avg/max/mdev = 206.299/209.139/211.979/2.840 ms } [_sysname]= 
 string(5) linux [_round_trip]=  array(3) { [min]= string(7)
 209.139 [avg]=  string(7) 211.979 [max]=  string(5) 2.840 }
 [_transmitted]=  string(1) 2 [_received]=  string(1) 2
 [_loss]= int(0) }


 Now I would like to retrieve my needed info out of it. How do I do this?
 (sounds a bit silly this question, sorry :-)

 I tried:
 $ping_result = $ping-ping('php.net');
 echo $ping_result[net_ping_result][_raw_data][5];

 But this and other tries did not work. My goal is to find out wheter a
 specified site is reachable.

 Can anybody give me a hint on this one?

 Thank you in advance,

 Merlin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] object oriented syntax in php

2006-03-28 Thread Stut

Merlin wrote:
snipped unformatted

Now I would like to retrieve my needed info out of it. How do I do 
this? (sounds a bit silly this question, sorry :-)


I tried:
$ping_result = $ping-ping('php.net');
echo $ping_result[net_ping_result][_raw_data][5];

But this and other tries did not work. My goal is to find out wheter a 
specified site is reachable.



Next time you want to post data like that please copy and paste the 
source not the browser output...


object(net_ping_result)(11)
{
   [_icmp_sequence]=array(1)
   {
   [61.117):]= string(1) 7
   }
   [_target_ip]=  string(9) y2.php.ne
   [_bytes_per_request]=  string(2) 64
   [_bytes_total]=  int(192)
   [_ttl]=  string(6) _seq=2
   [_raw_data]=array(7)
  {
  [0]=  string(72) PING php.net (66.163.161.117) 
from 192.168.1.114 : 56(84) bytes of data.
  [1]=  string(72) 64 bytes from y2.php.net 
(66.163.161.117): icmp_seq=1 ttl=47 time=211 ms
  [2]=  string(72) 64 bytes from y2.php.net 
(66.163.161.117): icmp_seq=2 ttl=47 time=206 ms

  [3]=  string(0) 
  [4]=  string(31) --- php.net ping statistics ---
  [5]= string(55) 2 packets transmitted, 2 
received, 0% loss, time 1008ms
  [6]= string(55) rtt min/avg/max/mdev = 
206.299/209.139/211.979/2.840 ms

  }
   [_sysname]=  string(5) linux
   [_round_trip]=array(3)
{
   [min]= string(7) 209.139
   [avg]=  string(7) 211.979
   [max]=  string(5) 2.840
}
   [_transmitted]=  string(1) 2
   [_received]=  string(1) 2
   [_loss]= int(0)
}

This is the output of a call to var_dump. What you probably want is 
$ping_result['_raw_data'][5]. However, since the class has nicely 
extracted the details you may be better off using the _transmitted, 
_received and _loss members.


I'm not familiar with the class in question, but given the names of the 
member variables I would expect there are accessor methods that you 
should be using instead of pulling the data out manually.


-Stut

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] object oriented syntax in php

2006-03-28 Thread Sameer N Ingole

Merlin wrote:

Hi there,

I do have problems with object oriented syntax as this is not familar 
to me.

There is following output:
[snip]
Now I would like to retrieve my needed info out of it. How do I do 
this? (sounds a bit silly this question, sorry :-)


I tried:
$ping_result = $ping-ping('php.net');
echo $ping_result[net_ping_result][_raw_data][5];

But this and other tries did not work. My goal is to find out wheter a 
specified site is reachable.

Why not use something like this
---code start---
if($ping-checkhost(php.net))
   echo I'm up;
else
   ding!!;
---code end---
if you are using PEAR



--
Sameer N. Ingole
Blog: http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] object oriented syntax in php

2006-03-28 Thread Robin Vickery
On 28/03/06, Merlin [EMAIL PROTECTED] wrote:
 Hi there,

 I do have problems with object oriented syntax as this is not familar to me.
 There is following output:



 Now I would like to retrieve my needed info out of it. How do I do this? 
 (sounds
 a bit silly this question, sorry :-)

 I tried:
 $ping_result = $ping-ping('php.net');
 echo $ping_result[net_ping_result][_raw_data][5];

You'd be much better using the interface to Net_Ping_Result that's
provided. Then your code won't break if someone decides to rearrange
the internals of the class.

$ping_result-getMin();
$ping_result-getMax();
$ping_result-getAvg();
$ping_result -getTransmitted();
$ping_result-getReceived();
$ping_result-getLoss();
...


 -robin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php