I have a Switches.js javascript file, like this:
//GLOBAL switches
//Change the values accordingly
var SWITCHES = {
uber: true, //Uber
social: true, //Social media pulgins
g_charts: true, //Google Charts
g_captcha: true, //Google Captcha
g_analytics: true, //Google Analytics
data_base: true, //Inserts user input data into DataBase
print: true, //Print option
pdf: true, //Download PDF report option
https: true //true for https, false for http
};
This JS file is stored in my server.
Is there a way to get that object and one of those properties into a php variable? I think that should be around the php functions file_get_contents and json_decode, but how do I take into account the comments in the JS file and that variable SWITCHES in particular?
$file_content = file_get_contents("Switches.js");
//some stuff
$http_switch = $SWITCHES[https];
AJAX nor jQuery are an option because this is to be run purely server side.
json_decode(). How about converting theSwitches.jstoSwitches.jsoninstead?SWICTHESvariable in my global JS scope?JSON.decode()to turn it into a JavaScript Object.:)JSON.decode()is meant to beJSON.parse().