I’ve always been awed at the simplicity of PHP, and been trying to find a good way to dump source without copy and pasting the file into a text/plain format.
Steps:
1. Create a source function ie
<?php
/************************************
Date: January 21, 2012
Author: LittleBearZ
Website: http://www.littlebearz.com/
E-mail: open-sourced@littlebearz.com
License:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************/
/***********************************
* The below view_source(); calls upon
* the big method to be used
* whereas function view_source(){}
* defines what's in this function
************************************/
view_source();
function view_source()
{
if (isset($_GET['source']))
{
header("Content-type: text/plain");
readfile(__FILE__);
}
}
?>
2. How to use
In a web browser, visit to that PHP page with ?source as ending, ie.
