php ini vs json and halt compiler hack -


i debating on using either configuration.ini or config.json administration dashboard designing. ini more configuration purposes todays interest in json seems more logical configurations designed json in mind.

question here should use json sure? , secondly have hack on configuration.ini file prevents file being seen publicly.

;<?php exit(); __halt_compiler(); ; //to stop script execution if not used in our best interest! ; //remember format    //ini stuff  ;?> 

i wondering if use json file well? haven't tested because didn't want nothing strange screwing up.as description why works, know won't work json since ; ini based commenting transformed // or /**/ json?

for interest purposes admin__autoload.php page

set_include_path(dirname($_server["document_root"]));    $ini = parse_ini_file("configurations.ini",true); foreach($ini $section=>$values) {     foreach($values $key=>$value )   {         define("__".strtoupper($key)."__",$value);     } }  spl_autoload_register(function($class) {         if(!file_exists(get_include_path(). directory_separator .__admin__."classes/{$class}.php")) {             echo get_include_path(). directory_separator .__admin__."classes/{$class}.php not exist";         } else {             include_once get_include_path(). directory_separator .__admin__."classes/{$class}.php";         } }); 

__admin__ created foreach loop ini file.

i think you're asking 2 different questions here.

  1. which configuration format best suite needs
  2. how prevent configuration files being accessed public

the answer 2 easy. don't put configuration files in public document root.

as far choosing between ini or json, it's rather subjective without understanding use case clearly.

ini more expressive reader harder parse. json quite portable serialization format, harder read human.

so if you're manually editing configuration file lot, makes sense go ini disambiguated json. if you're doing editing through autonomous process or 1 otherwise requires portability across disparate systems, json may more convenient.

a third alternative yaml, middle ground between human-readable aspect of ini, , portability of json.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -