Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5346

Re: pass arbitrary vars into a func from another func?

From Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de>
Newsgroups comp.lang.php
Subject Re: pass arbitrary vars into a func from another func?
Date 2012-04-04 22:58 +0200
Organization albasani.net
Message-ID <jlicla$vid$1@news.albasani.net> (permalink)
References <29aa0c10-43ad-4b6e-9d4d-34e84b89a1ba@h4g2000pbe.googlegroups.com>

Show all headers | View raw


J. Frank Parnell schrieb:

> 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.

You want <www.php.net/call-user-func-array>:

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

Greetings,
Thomas

-- 
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

pass arbitrary vars into a func from another func? "J. Frank Parnell" <juglesh@gmail.com> - 2012-04-04 10:52 -0700
  Re: pass arbitrary vars into a func from another func? Thomas Mlynarczyk <thomas@mlynarczyk-webdesign.de> - 2012-04-04 22:58 +0200
    Re: pass arbitrary vars into a func from another func? "J. Frank Parnell" <juglesh@gmail.com> - 2012-04-05 13:14 -0700
    Re: pass arbitrary vars into a func from another func? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-04-06 11:51 +0200

csiph-web