PHP file_get_contents after php has evaluated

Posted on

PHP file_get_contents after php has evaluated – Here in this article, we will share some of the most common and frequently asked about PHP problem in programming with detailed answers and code samples. There’s nothing quite so frustrating as being faced with PHP errors and being unable to figure out what is preventing your website from functioning as it should like php and import . If you have an existing PHP-based website or application that is experiencing performance issues, let’s get thinking about PHP file_get_contents after php has evaluated.

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

Solution :

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)) {
        include $filename;
        $contents = ob_get_contents();
        return $contents;
    return false;

Leave a Reply

Your email address will not be published. Required fields are marked *