|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I'm using PHP 5. How do I tell if an array contains objects or pointers to objects? Thanks, - Dave |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
laredotornado@zipmail.com schreef:
> Hi, > > I'm using PHP 5. How do I tell if an array contains objects or > pointers to objects? Hi, Start with dumping the array, using print_r(). eg: // $mysteryArr = ???; then: echo "<pre>"; print_r($mysteryArr); echo "</pre>"; > > Thanks, - Dave Regards, Erwin Moller |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
laredotornado@zipmail.com wrote:
> Hi, > > I'm using PHP 5. How do I tell if an array contains objects or > pointers to objects? 1) References are not pointers. 2) Be it reference or not, you access the objects in exactly the same way. Why do you need this? In PHP 5 objects are always passed by reference BTW, so usually you don't need no weird &'s for that. Var_dump will show a & if something is a reference. -- Rik Wasmus ....moving deadlines for your pleasure. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Rik Wasmus wrote:
> laredotornado@zipmail.com wrote: >> Hi, >> >> I'm using PHP 5. How do I tell if an array contains objects or >> pointers to objects? > > 1) References are not pointers. > 2) Be it reference or not, you access the objects in exactly the same way. > > Why do you need this? In PHP 5 objects are always passed by reference > BTW, so usually you don't need no weird &'s for that. That makes sense. Is that the only thing passed by reference? Jeff > > Var_dump will show a & if something is a reference. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Jeff wrote:
> Rik Wasmus wrote: >> laredotornado@zipmail.com wrote: >>> Hi, >>> >>> I'm using PHP 5. How do I tell if an array contains objects or >>> pointers to objects? >> >> 1) References are not pointers. >> 2) Be it reference or not, you access the objects in exactly the same >> way. >> >> Why do you need this? In PHP 5 objects are always passed by reference >> BTW, so usually you don't need no weird &'s for that. > > That makes sense. Is that the only thing passed by reference? - Objects are passed by reference by default. - Arrays & scalars are only passed by reference it explicitly set (&). - Resources are a a league of their own, just check what their associated functions do. Sometimes, having references to them does matter: <?php $h = fopen(__FILE__,'r'); $a = &$h; $b = $h; var_dump($h,$a,$b); fclose($h); var_dump($h,$a,$b); fclose($a); var_dump($h,$a,$b); ?> -- Rik Wasmus ....moving deadlines for your pleasure. |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
..oO(Rik Wasmus)
>Jeff wrote: > >> That makes sense. Is that the only thing passed by reference? > >- Objects are passed by reference by default. It should be mentioned and kept in mind that these are _not_ the same references as created with an explicit '&', but internal object handles. '=' and '=&' are still two different things, even when working with objects in PHP 5. See example #6 (Object Assignment) on http://de2.php.net/manual/en/language.oop5.basic.php for a short demonstration of the differences. Micha PS: Anyone else having problems with <http://www.php.net> currently? Ping and traceroute work from here, but the web server doesn't want to talk with me ... |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Fri, 20 Jun 2008 19:14:10 +0200, Michael Fesser <netizen@gmx.de> wrote:
> .oO(Rik Wasmus) > >> Jeff wrote: >> >>> That makes sense. Is that the only thing passed by reference? >> >> - Objects are passed by reference by default. > > It should be mentioned and kept in mind that these are _not_ the same > references as created with an explicit '&', but internal object handles. > '=' and '=&' are still two different things, even when working with > objects in PHP 5. > > See example #6 (Object Assignment) on > > http://de2.php.net/manual/en/language.oop5.basic.php > > for a short demonstration of the differences. Yup, that's why I asked why he needed it for. > PS: Anyone else having problems with <http://www.php.net> currently? > Ping and traceroute work from here, but the web server doesn't want to > talk with me ... That's been the case for me for months, the server being either very slow or not responsive at all, although it just seemed to get better the last few days. I've just grown accustomed to using nl2. or nl3. ![]() -- Rik Wasmus ....spamrun finished |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Greetings, Michael Fesser.
In reply to Your message dated Friday, June 20, 2008, 21:14:10, > PS: Anyone else having problems with <http://www.php.net> currently? > Ping and traceroute work from here, but the web server doesn't want to > talk with me ... I've had problem with ru2, but that was a DNS change, what my DNS server wasn't reflected. I've forced it to recheck DNS records and it is ok now. No problem with www.php.net for long time. -- Sincerely Yours, AnrDaemon <anrdaemon@freemail.ru> |
|
![]() |
| Outils de la discussion | |
|
|