Created
October 4, 2009 19:08
-
-
Save nickkeers/201561 to your computer and use it in GitHub Desktop.
json parser
This file contains 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 | |
/** | |
* @author Nick keers | |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License | |
*/ | |
/** | |
* Paradox_jsonParser - Main use is to read config | |
* values, but im sure you can find another use ! | |
* | |
* @author Nick | |
*/ | |
class Paradox_jsonParser | |
{ | |
public $config = NULL; | |
public function __construct($file) | |
{ | |
if(!strpos($file,".json")) | |
{ | |
return false; | |
} | |
else | |
{ | |
$c = file_get_contents($file); | |
$m = json_decode($c); | |
$this->config = $m; | |
unset($m); | |
return true; | |
} | |
} | |
public function getSetting($setting) | |
{ | |
if(!is_null($this->config)) | |
{ | |
return $this->config[$setting]; | |
} | |
else{ | |
return false; | |
} | |
} | |
} | |
?> | |
// And the settings.json file | |
{ | |
"Title":"Nick keers - ", | |
"Mode":"Development", | |
"Description":"The website of Nick keers- Javascript, PHP and general programming enthusiast", | |
"Footer":"Copyright © Nick Keers, 2009", | |
"Version":"1.0.0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment