Вопрос

If you need to return an array from php ob_start instead of contents how do you do this?

If a return variable is defined I want the return value instead of the default contents output.

Это было полезно?

Решение

This is how I got this to work:

ob_start();
extract($passedData, EXTR_SKIP);
include($fileToInclude);
if(isset($_return)){
    $this->result = $_return;
} else {
    $this->result = ob_get_contents(); 
}
ob_end_clean();

Now if the template file has a variable named $_return defined it will be returned instead of the normal ob contents.

If there is a better way of doing this please let me know.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top