Created
September 4, 2018 08:10
-
-
Save artemsites/89e7990203e51e7ac4651defe26eb586 to your computer and use it in GitHub Desktop.
Включение файла PHP в строку при помощи буферизации.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Использование буферизации вывода для включения файла PHP в строку. | |
* http://php.net/manual/ru/function.ob-start.php | |
* http://php.net/manual/ru/function.ob-get-clean.php | |
*/ | |
$string = get_include_contents('somefile.php'); | |
function get_include_contents($filename) { | |
if (is_file($filename)) { | |
ob_start(); | |
include $filename; | |
return ob_get_clean(); | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment