Jump to content

Is there a function that prints the interpreted php code?


Recommended Posts

I've been making our thesis and i've been thinking if there is a function or method perhaps to

get the interpreted codes(the codes you see if you get the source of the site on browsers) into another text file.

 

something like

 

fwrite the intertpreted code to a text file

Sure, this should work.

 


$filename = 'myfile.php';  //file whos output you want to capture.
$storageFile = 'myfile.html'; //file where you want to store the data.

$file = file_get_contents($filename);
file_put_contents($storageFile,$file);

Thank you but,

It just like replicated the main php file.

i want the interpreted code to be stored, the html codes you see in viewing your source in browser

 

 

brower>>view>>sourcecode

 

this source code is the html code i want to store, is this possible?

 

thank you

I tested it on my login.php. By The Way I tested the first one here too

my server took a while to respond and gave me this error

 

Warning: file_get_contents(http://localhost/thesis/login.php) [function.file-get-contents]: failed to open stream: HTTP request failed! in C:\xampp\htdocs\thesis\login.php on line 16

 

Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\thesis\login.php on line 16

 

Line 13 $filename = 'http://localhost/thesis/login.php';  //file whos output you want to capture.

Line 14 $storageFile = 'test.html'; //file where you want to store the data.

Line 15    // Blank line

Line 16 $file = file_get_contents($filename);

Line 17 file_put_contents($storageFile,$file);

 

Is there something wrong in naming the URL?

Thank you

Your code needs to be accessed via a url in order for the server to execute it.

 

The other thing you could do would be to use output buffering to trap all output in a buffer, then write that output to a file. This will likely require modification of your code however unless you setup auto_prepend_file to enable the buffer and auto_append_file to write the file.

 

Take a look at ob_start.

oh yea i just remebered i placed

output_buffering = on

on my php.ini

do you think this is a factor in this matter?

 

I'm a little new to php scripting and not used to most of its functions,

I've read  Php manual the .chm file but

it says that

ob_start -- Turn on output buffering

oh yea i just remebered i placed

output_buffering = on

on my php.ini

do you think this is a factor in this matter?

 

I'm a little new to php scripting and not used to most of its functions,

I've read  Php manual the .chm file but

it says that

ob_start -- Turn on output buffering

 

Output buffering doesn't really help you unless you plan on using what's in the buffer. It has nothing to do with the issue you posted above, I was suggesting it as another possible solution to your overall problem though.

i tried to do it like this,

i placed <?php ob_start() ?>

at the first line of the file then

 

placed this on the last part

 

$str = ob_get_contents();

$storageFile = 'test.html'; //file where you want to store the data.

file_put_contents($storageFile,$str);

 

but it seems that it doest make the test.html file

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.