Reputation: 1
I have to include a file stored in a database and retrieved as a variable. how can I do it? I have tried this line but it doesn't work include_once("News/$post->newspage"); the fild newspage contains the names of the files stored in News folder. for example his line works. include_once("News/labourday2014.php");
Upvotes: 0
Views: 1404
Reputation: 1
You can try this -
$fileName="News/".$post->newspage;
include_once($fileName);
Upvotes: 0
Reputation: 983
Verify if the file exist then include it
if(is_file("News/".$post->newspage)) {
include_once("News/".$post->newspage);
} else {
// File dosent't exist
echo "File dosent't exist";
}
Upvotes: 1