Do it like this:
$content = include ('list.php');
instead instead of using file_get_contents
returning string, use $content;
that way the $content
will contain the outputted string from list.php
Question
On my website, I'm using a php class called mpdf http://www.mpdf1.com/mpdf/index.php to create a pdf for users to download.
It works by using a file_get_contents('list.php')
function to get the contents as html, ready to convert into pdf.
It works really well, but unfortunately with my site it only returns the actual php code, not the resulting html:
<?php include 'inc/head.php'?>
<?php include 'inc/header.php'?>
<?php include 'inc/gold_packageinc.php'?>
<?php include 'inc/footer.php'?>
If I could figure out how to use
exec('list.php')
before
file_get_contents('list.php')
I'm sure it would work. The thing is it seems really hard to do. Apparently you need to reference the php files or something, but I can't do it. I've created a fair whack of php-driven sites now, but I don't know what a 'shell' is or anything!
If someone could explain how to get exec('list.php') to work, I'd be very grateful! Completely open to work arounds. Maybe 'output buffering' if someone could explain?
Solution
Do it like this:
$content = include ('list.php');
instead instead of using file_get_contents
returning string, use $content;
that way the $content
will contain the outputted string from list.php
OTHER TIPS
exec('list.php') is wrong,If you need to execute a php file with exec() function,You need to pass the name of file as argument to PHP.exe file
eg:
exec('C:/xampp/bin/PHP.exe "C:/xampp/htdocs/list.php"');
You need to given the full path of that file