What is the best place to define global constants in an SC project? e.g.
define('GREETING', 'hello');
Defining within regular apps means it is redefined each time the script runs and I do not want to check if defined each time also.
What is the best place to define global constants in an SC project? e.g.
define('GREETING', 'hello');
Defining within regular apps means it is redefined each time the script runs and I do not want to check if defined each time also.
in your login you can create global variables:
onvalidate success
[GREETING] = ‘hello’;
Yeah but every session has a copy. I want PHP “define” behaviour if possible.
I don´t understand you want.
You can assign a value from a variable to Global.
$hello_from_sql = “your query”;
[GREETING] = $hello_from_sql;
I agree with alvagar. The best spot to create global variables is at the loginpage. Main reason is that you will have them all defined at the same place that is run before any other application so that you won’t run into an issue like undefined global variable when you miss the application that defines it.
Thank you both. What you are suggesting definitely works though when you use define in raw PHP, I think the constant is stored only once for the entire app (like a singleton). I guess I’m nit-picking or being too much of a purist: memory is cheap enough.
One thing if you have much global variables, you can use a global array with all your vaiables.
Mmmm, what is the profit? If you have raw php it might be convenient, but in scriptcase all globals are set in [] and are referenced that way. I don’t see benefit using arrays here?
In my case i have a project that use much global variables and i use them in various forms, and i need classify it. so my forms just ask by one variable global.
in the same way I have some projects that do not use many global variables and I do not use the array.
In the loginpage is best solution and I use a prefix like ‘glb_’ so you can immediately identify them in all applications.