echo vs return
-
Hi folks,
Just thought I’d share a word about a small frustration I’m having with WP. It’s a great tool (I’m currently migrating from MT), and the fact you can create your own functions/ plug-ins makes it really extensible.
That said, if you wanna use internal functions within your own, there seems to be little consistency in the way each returns data – sometimes they useecho
and sometimes they usereturn
. Of course, that’s not always what you want.
On some functions, you can pass the parameterecho="true
, which is great. Alas, it’s not always there (on comment_count, for instance), which means you have to copy the internal function, hack it about a bit and save it in my_hacks or as part of the plug-in.
Maybe something to consider going forward – ensure all internal functions have a parameter switch for how they output so they can be invoked either in templates, or as part of a plug-in.
Just my two cents…
- The topic ‘echo vs return’ is closed to new replies.