[wp-hackers] Returning instead of echoing

Ryan Boren ryan at boren.nu
Tue Nov 9 00:33:37 UTC 2004


On Mon, 2004-11-08 at 00:31 -0500, Mark Jaquith wrote:
> David House wrote:
> > See previous discussion. We've had a huge thread [1] on this topic already. I
> > had a proposal [2] which I still think is a good idea. It would probably be
> > worth extract()ing this array inside the function, so inside the function you
> > can use $foo instead of $args['foo']. Of course, using compact() as a way of
> > creating the parameter-arrays is a good idea as well.
> I thought it was a great idea, and still do.  This was one of the
> first things about WordPress that I noticed when I started first
> examining the code.  A lot of my early hacking involved taking
> existing functions, adding "get_" to the front of the function name,
> and changing the echoes into returns, and saving in my-hacks.php.  I
> absolutely empathize with newbies who may be confused by "echo," but
> really, what newbie understands <?php function(); ?>  right away?  I
> think that if we can expect them to pick up that much syntax, we can
> reasonably expect them to catch on to "echo."  David also has many
> good ideas on different ways this issue can be fixed.  None may be
> ideal, but I think method 5 is the best option.  I don't want to start
> a big thing, but the last time this came up, there was really no
> resolution or closure.  The people subscribed to this list are the
> people who help expand WordPress's capabilities through hacks and
> plugins, and this is an issue that, if resolved, would make life a
> whole lot easier for us.

I personally prefer adding get_*() functions.  As for passing in arrays,
I'd rather not require that in the templates, even with the assistance
of compact().  As Matt mentioned last time this came up, we use the URI-
like syntax that can be fed to parse_str() when we want to pass in a
bunch of named arguments.

Ryan




More information about the hackers mailing list