[wp-hackers] Returning instead of echoing

Robert Deaton false.hopes at gmail.com
Sun Nov 7 14:20:08 UTC 2004


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.



More information about the hackers mailing list