Loading php script and saving output to HTML
Moderator: General Moderators
Loading php script and saving output to HTML
Here's a n00b question for you...
I can't for the life of me figure out how to call a PHP file from my main PHP file and save the result into an HTML file. I've tried everything, but surely there's a way to do this...help! Thanks in advance.
-j
I can't for the life of me figure out how to call a PHP file from my main PHP file and save the result into an HTML file. I've tried everything, but surely there's a way to do this...help! Thanks in advance.
-j
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
You want to physically create a file rather than sending the output back to the browser?
A shell access method:
A 100% PHP method:
EDIT | Addeell access method:
A 100% PHP method:
A 100% PHP method:
A 100% PHP method:
A 100% PHP method:
A 100% PHP method:
A 100% PHP method:
EDIT | Added some examples.
system('php thescript.php > thehtmlfile.html');
A 100% PHP method:
EDIT | Added some examples.
A shell access method:
Code: Select all
system('php thescript.php > thehtmlfile.html');Code: Select all
$data = file_get_contents('http://localhost/thescript.php?args=values'); //http portion in tact so apache runs it
$handle = fopen('thehtmlfile.html', 'w');
fwrite($data, $handle);
fclose($handle);Code: Select all
system('php thescript.php > thehtmlfile.html');Code: Select all
$data = file_get_contents('http://localhost/thescript.php?args=values'); //http portion in tact so apache runs it
$handle = fopen('thehtmlfile.html', 'w');
fwritocalhost/thescript.php?args=values'); //http portion in tact so apache runs it
$handle = fopen('thehtmlfile.html', 'w');
fwrite($data, $handle);
fclose]
system('php thescript.php > thehtmlfile.html');Code: Select all
$data = file_get_contents('http://localhost/thescript.php?args=values'); //http portion in tact so apache runs it
$handle = fopen('thehtmlfile.html', 'w');
fwrite($data, $handle);
fclose($handle);
[/php:1:f502g the output back to the browser?
A shell access method:Code: Select all
system('php thescript.php > thehtmlfile.html');Code: Select all
$data = file_get_contents('http://localhost/thescript.php?args=values'ally create a file rather than sending the output back to the browser?
A shell access method:Code: Select all
system('php thescript.php > thehtmlfile.html');Code: Select all
$data = file_get_contents('httally create a file rather than sending the output back to the browser?
A shell access method:Code: Select all
system('php thescript.php > thehtmlfile.html');Code: Select all
$data = file_get_contents('http://localhost/thescript.php?argthod:Code: Select all
system('php thescript.php > thehtmlfile.html');Code: Select all
$data = file_get_contents('http://localhost/thescript.php?args=values'); //http portion in tact so apache runs it
$handle = fopen('thehtmlfile.html', 'w');
fwrite($data, $handle);
fclose($handle);system('php thescript.php > thehtmlfile.html');
A 100% PHP method:
Code: Select all
$data = file_get_contents('http://localhost/thescript.php?args=values'); //http portion in tact so apache runs it
$handle = fopen('thehtmlfile.html', 'w');
fwrite($data, $handle);
fclose($handle);
Last edited by Chris Corbyn on Wed Jul 06, 2005 1:15 pm, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia