[thelist] another php question: object reference syntax

Tom Dell'Aringa pixelmech at yahoo.com
Wed Jul 17 15:50:00 CDT 2002


Ok, that makes sense. I seem to remember this talk about pointers
when going through a Java class, and you often see those caveats in
Java books (at least that I have read.) Coming from Java/JavaScript
it seemed odd.

So - I CAN use dot syntax, but if I make a pointer, I have to use ->
correct?

Tom
--- Jonathan_A_McPherson at rl.gov wrote:
> Tom,
>
> This is an inherited trait from the programming language that PHP
> derives
> much of its syntax from -- C.
>
> In C, suppose I have an object named "bar" that has a method named
> do_foo.
>
> I can say:
>
> bar.do_foo();
>
> and it'll work fine. Now, suppose I create a _pointer_ to bar
> called quux:
>
> quux = &bar;
>
> quux is not bar; it's a pointer to bar. Therefore, I cannot say
>
> quux.do_foo();
>
> ... I must instead say
>
> quux->do_foo();
>
> ... which tells C to follow the pointer "quux." So in your example,
> "bar" is
> likely a reference/pointer to an object with a do_foo() method, not
> an
> actual object.
>
> The syntax may seem odd, but it is exactly what many open-source
> developers
> are used to, if they've ever done much work with C/C++ -- and most
> of them
> have.
>
> --
> Jonathan McPherson, LMIT/SD&I
> Software Engineer & Web Systems Analyst
> email / jonathan_a_mcpherson at rl dot gov
>
> -----Original Message-----
> From: Tom Dell'Aringa [mailto:pixelmech at yahoo.com]
> Sent: Wednesday, July 17, 2002 1:20 PM
> To: thelist at lists.evolt.org
> Subject: [thelist] another php question: object reference syntax
>
>
> So far I can't find this in the manual so I'll ask here - I keep
> seeing references to ojbect references in php as:
>
> $bar->do_foo();
>
> -> is about the silliest thing I've ever seen. PLEASE tell me you
> can
> do $bar.do_foo(); like the rest of the universe does...
>
> WHY would I want to constantly type "-" and ">", one a shift
> character, one not, on opposite top/bottom of the keyboard, when I
> can simply hit the period with finger? For an open source language,
> that is truly nuts.
>
> Tom
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !


=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com



More information about the thelist mailing list