本文介紹了php 評估后的 PHP file_get_contents的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我知道如何使用 file_get_contents 和 fopen 等,但是當我對我自己的一個文件執(zhí)行此操作時,我得到了文字字符串,意思是,代碼沒有經(jīng)過預處理!如何在不使用 require 等的情況下從文件中導入文本,因為我想將值存儲到字符串中
I know how to use file_get_contents and fopen etc, but when I do it to one of my own file, I get the literal string, meaning, the code is not preprocessed! How can i import text from a file without using require etc. because I want to store the value into a string
推薦答案
參見 手冊.直接從那里取的:
See examples #5 and #6 on the manual. Taken straight from there:
$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;
}
這篇關(guān)于php 評估后的 PHP file_get_contents的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!