php output current file contents without file reading functions
I have an interesting task here.. is it possible to read the current file contents without file reading functions? (without file_get_contents, fopen etc.)
so if i have
<?
echo 'hi';
// function to output this file code
?>
the output of th开发者_高级运维e php file should be same as the code (BUT without the file reading functions)
You can configure Apache to serve up PHP files as formatted source code with:
AddHandler application/x-httpd-php-source .phps
This'd make any .phps
files be served up as source instead of executed. If you want a particular file to be served up, but also still be executable as an actual PHP script, you can create a symlink to it, and give the symlink a .phps extension.
You can always change your apache/webserver config to serve php files as text (without running the code).
No, this is not possible. You will need to use file functions to open the file and read it.
If you are looking for specific properties of your code, you could try using the reflection API: http://www.php.net/manual/en/book.reflection.php
If you just want to display the code, you can use the highlight_file/highlight_string functions: http://www.php.net/manual/en/function.highlight-file.php
精彩评论