Search code examples
phpsidebarvbulletin

Assigning a variable equal to Include function content


This issue came up to me in vBulletin system. i want to build a block in sidebar area to help me autmate some daily works.. i wrote php code like this :

<?php
    $myDay = date('D');
    $myHour = date('G');
    // Saturday
    if ($myDay == "Sat") {
        if ($myHour >= 7) {
            $output = include('textFilePath/saturday.txt');
        } else {
            $output = include('textFilePath/friday.txt');
        }
    }
    // Sunday
    if ($myDay == "Sun") {
        if ($myHour >= 7) {
            $output = include('textFilePath/sunday.txt');
        } else {
            $output = include('textFilePath/saturday.txt');
        }
    }
    // and it goes on to friday...
    // and in the end :
    return $output;
?>

my problem is with include() function . when i return the $output value it returns a boolean(0 or 1) and include function writes out the txt files content in the beginning of document instead of "sidebar block" i know i can echo the actual content instead of using include and txt files. but as i said i want to automate the daily tasks and give the users access to edit the txt files.

is there any other technique or function to assign the content of a local file to a variable ?


Solution

  • you may want to check

    $output = file_get_contents('textFilePath/saturday.txt');
    

    more information here : https://www.php.net/file_get_contents