Created
December 13, 2016 16:02
-
-
Save khaeransori/429519fb4a0a3b024299c2cf8744fafd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
const FILENAME = 'loadlog.ini'; | |
const FILEPATH = './' . FILENAME; | |
$foo = $_POST['foo']; | |
$bar = $_POST['bar']; | |
$content = 'foo=' . $foo; | |
$content .= '\n'; // \n are ascii code for breakline a.k.a enter | |
$content .= 'bar=' . $bar; | |
// write to file first if there's payload | |
if ($foo || $bar) { | |
file_put_contents(FILEPATH, $content); | |
} | |
// read file and parse it | |
$parsed_file = parse_ini_file(FILEPATH); | |
/** | |
* it should be parsed to array | |
* so you can access it like $parsed_file['foo'] | |
*/ | |
print_r($parsed_file); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment