[drupal-devel] Why the object notation?

Earl Dunovant prometheus6 at gmail.com
Thu Jul 28 13:08:19 UTC 2005


I perfer the object notation because it (when using double quotes) 
makes string manipulations easier, and easier to read:

"Title: <h2>$node->title</h2>" vs. 'Title: <h2>' . $node['title'] . '</h2>'

On 7/28/05, Karoly Negyesi <karoly at negyesi.net> wrote:
> Hi!
> 
> Drupal code uses object notation very often and I fail to see why it's
> better than associative arrays. We get $_POST data in arrays so we need to
> convert back and forth.
> 
> We never use the class construct. So why the -> ?
> 
> It seems like the change can be done with at most two simple regexp
> replaces.
> 
> Regards
> 
> NK
> 
> Ps. I think it's OK to initialize an array by $array['foo'] = 'bar'; this
> needs two steps with object notation. Only $array[] needs initialization.
>



More information about the drupal-devel mailing list