[wp-hackers] Returning instead of echoing

Robert Deaton false.hopes at gmail.com
Sun Nov 7 15:43:30 UTC 2004


Well, if I remember correctly, a lot of the function calls used in the
template call other functions that return the value and then echo the
value returned by the function, so maybe we should search through the
core and make a list of these functions that are used in the template
functions for the advanced users to use, and leave alone the template
functions for the newbies.


On Sun, 7 Nov 2004 15:43:10 +0100, Michael Heilemann
<michael at binarybonsai.com> wrote:
> But that's sacrificing the usability of the functions for the advanced
> users over the newbies. Meaning, that instead of teaching people to
> write 'echo ', we're forcing advanced users to hack up the core engine
> for something as simple as returning a value...
> 
> But I've noticed that in WP13 at the_category_ID can be fed a parameter
> to return the value rather than echo it. Hopefully all functions will
> work that way.
> 
> 
> 
> Aloha, Mike
> http://binarybonsai.com
> 
> On 7/11-2004, at 15.20, Robert Deaton wrote:
> 
> > I think the actual reason why a lot of functions echo rather than
> > return is for simple hackability to new users. Its a lot easier to put
> > in simple things like <?php the_title(); ?> than <?php echo
> > the_title(); ?> for new users, and they may not realize fully why it
> > is this way or might not remember to put in all the echos.
> >
> >
> > On Sat, 6 Nov 2004 13:59:35 -0700, Alex King <alex at alexking.org> wrote:
> >> An easy way to get the echoed/printed content into a variable:
> >>
> >> <?php
> >>
> >> ob_start();
> >> the_title();
> >> $my_title = ob_get_contents();
> >> ob_end_clean();
> >>
> >> print($my_title);
> >>
> >> ?>
> >>
> >> --Alex
> >>
> >> http://www.alexking.org/
> >>
> >>
> >>
> >>
> >> On Nov 6, 2004, at 1:46 PM, Michael Heilemann wrote:
> >>
> >>> I've been wondering for some time now. In fact, ever since I started
> >>> to learn a bit of PHP, so that I could write Kubrick
> >>> (binarybonsai.com/kubrick), why on God's green Earth the majority of
> >>> the functions in WordPress echo rather than return their results?
> >>>
> >>> I can't really come up with any particular reason for doing it this
> >>> way, rather than simply returning the result for easy inline parsing
> >>> if needed...
> >>>
> >>> The way it is now, when I for instance want to add a title="" to the
> >>> comment link, I have to dig out the code somewhere inside the core of
> >>> WordPress and change it. Which I can deal with... Until the next
> >>> version rolls around and I have to deal with upgrading my hacked
> >>> codebase.
> >>>
> >>> If instead comments_popup_link was divided into two seperate
> >>> functions, one for fetching the URI, and one for fetching the number
> >>> of comments, I could echo them out and do whatever the devil I wanted
> >>> with them...
> >>>
> >>> Am I missing something?
> >>>
> >>> Aloha, Mike
> >>> http://binarybonsai.com
> >>>
> >>>
> >>> _______________________________________________
> >>> hackers mailing list
> >>> hackers at wordpress.org
> >>> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
> >>
> >> _______________________________________________
> >> hackers mailing list
> >> hackers at wordpress.org
> >> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
> >>
> >
> >
> > --
> > --Robert Deaton
> > http://false-hopes.com/
> > A proud Linux, Firefox, and WordPress user.
> > Linux is not an operating system, its a way of life.
> >
> > _______________________________________________
> 
> 
> > hackers mailing list
> > hackers at wordpress.org
> > http://wordpress.org/mailman/listinfo/hackers_wordpress.org
> >
> >
> 
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
> 


-- 
--Robert Deaton
http://false-hopes.com/
A proud Linux, Firefox, and WordPress user.
Linux is not an operating system, its a way of life.



More information about the hackers mailing list