Запись в переменную результата вывода скрипта

  • Автор темы Автор темы dimardi
  • Дата начала Дата начала

dimardi

Guest
Запись в переменную результата вывода скрипта

Подскажите есть ли возможность в PHP зделать нечто подобное:

$str = require('myscrypt.php') ?
 
А чем не нравятся функции? Или это как обычно - ищем трудности там, где их нет?
 
return()

If called from the global scope, then execution of the current script file is ended. If the current script file was include()ed or require()ed, then control is passed back to the calling file. Furthermore, if the current script file was include()ed, then the value given to return() will be returned as the value of the include() call.
 
спасибки, всеже был бы признателен за пример использования..
 
dimardi
parent.php:
PHP:
ob_start();
include "child.php";
$str = ob_get_contents(); // child
ob_end_clean();
child.php:
PHP:
echo "child";
 
Сверху