Skip to content

Instantly share code, notes, and snippets.

@nickkeers
Created October 4, 2009 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickkeers/201561 to your computer and use it in GitHub Desktop.
Save nickkeers/201561 to your computer and use it in GitHub Desktop.
json parser
<?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 &copy; 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