FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » pass arbitrary vars into a func from another func?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
pass arbitrary vars into a func from another func? [message #177517] Wed, 04 April 2012 17:52 Go to previous message
J. Frank Parnell is currently offline  J. Frank Parnell
Messages: 12
Registered: January 2012
Karma:
Junior Member
In wordpress and probly other software, there are functions you can
use to echo stuff into your page. just call
comments_number('0','1','%');
and it echo the number of comments for the post. The problem is, you
cant use that to set up, eg, a link to be echo'd later in your page,
because it will echo it when you call it.

$var = comments_number('0','1','%');
wont work to put the number into your $var cuz it will just echo the
number.

so, something like
ob_start();
comments_number('0','1','%');
$commentsnum = ob_get_contents();
ob_end_clean();
works.

now i could wrap funcs into other funcs that would do that, but i was
wondering about a generic func i could pass the func name and an array
of vars that the func expected

function echoToVar($func,$args = array()){
ob_start();
$func($args);
$ret= ob_get_contents();
ob_end_clean();
return $ret;
}

but i'm not sure how to get the args into the variable func. Some
funcs that are expecting an array would work with what i have above,
but i dont see how i could use this with eg the comments_number()
function.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Lead an open source Project "Free Network and Office management system" in php or java
Next Topic: Lead an open source Project "Free Network and Office management system" in php or java.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 14:32:38 GMT 2024

Total time taken to generate the page: 0.06719 seconds