Re: Accessing class member with a parameterized name

Top Page
Author: PHP Web Development
Date:  
To: PHP Web Development
Subject: Re: Accessing class member with a parameterized name
this should work:

$result_object->$fieldname

hth


On 5/28/07, Andy Sy <andy.sy@???> wrote:
>
> My preferred method for getting MySQL results in PHP
> is via mysql_fetch_object() rather than mysql_fetch_array().
>
> This is because I find:
>
>    $result_object->fieldname

>
> clearner than:
>
>    $result_object['fieldname']

>
> However, I recently find myself needing to be able to
> parameterize the fieldname being accessed. So I'm
> being forced to do:
>
>    $result[$fieldname]  /* fieldname is assigned programatically */

>
> Question: Is there a way to accomplish the same thing
> for objects?
>
>
>
> ________________________________________________
> PHP Web Development Mailing List
> php@??? (#PHP @ irc.free.net.ph)
> http://lists.free.net.ph/mailman/listinfo/php
> Searchable Archives: http://archives.free.net.ph
>

________________________________________________
PHP Web Development Mailing List
php@??? (#PHP @ irc.free.net.ph)
http://lists.free.net.ph/mailman/listinfo/php
Searchable Archives: http://archives.free.net.ph