include (制御構造) - PHPプロ!マニュアル
例6 出力バッファリングを用い、 PHP ファイルの内容を文字列として読み込む
<?php
$string = get_include_contents('somefile.php');
function get_include_contents($filename) {
if (is_file($filename)) {
ob_start();
include $filename;
$contents = ob_get_contents();
ob_end_clean();
return $contents;
}
return false;
}
?>