I am trying to do system("cat variables.php"); from a php script but it doesn't write anything :( Anybody knows whats the problem?
If you want to display the entire file to users, try:
highlight_file("path/to/file");
You can use file_get_contents
to get the content of a file.
And you can use __FILE__
to get the path to the current file -- if you want the current file, of course
So, to display the content of the current file :
echo file_get_contents(__FILE__);
Note 1 : you might have to do some escaping :
echo '<pre>' . htmlspecialchars(file_get_contents(__FILE__)) . '</pre>';
Note 2 : you can do that with any file, of course -- just make sure the path to the file is correct :
echo '<pre>' . htmlspecialchars(file_get_contents('/path/to/my/file.php')) . '</pre>';
And if you want more than just display the content -- if you want syntax-highlighting -- you could use the highlight_file
function ; or something like GeSHi, which is more rich and more configurable.
Its not clear what you are trying to achieve, but if you are trying to step through your PHP code use:
These tools will allow you to view your variables at different points in time.
If you're trying to display the contents of the file in its entirety some servers are configured to display the source of PHP files with a file extensions of phps. It will also syntax highlight the file's contents when displaying it.