Possible to capture PHP echo output?

Typesmokesype

New Member
So I have a function such as: \[code\]public static function UnorderedList($items, $field, $view = false){ if(count($items) > 0){ echo '<ul>'; foreach($items as $item){ echo '<li>'; if($view){ echo '<a href="'.$view.'id='.$item->sys_id.'" title="View Item">'.$item->$field.'</a>'; }else{ echo $item->$field; } echo '</li>'; } echo '</ul>'; }else{ echo '<p>No Items...</p>'; }}\[/code\]This function loops over some items and renders a unordered list. What I am wondering is if its possible to capture the echo output if I wish. I make a call to use this function by doing something like: \[code\]Render::UnorderedList(Class::getItems(), Class::getFields(), true); \[/code\]And this will dump a unordered list onto my page. I Know I can just change echo to a variable and return the variable but I was just curious if its possible to capture echo output without modifying that function, merely modifying the call to the function in some way? Thanks!
 
Back
Top