global variables php [closed]

0
Hello, I think this is simple, I'm working on a project where I need to start 3 strings on 80% of the system pages in php, so what would be the best method for the user to just change the text in one document, and I can perform inclusion on all pages ???

explaining better, I'll create a config.php file, where the client will open using a compiler or text editor and set the value of the 3 strings, separately.

ps: I've been advised to use session, however my question is how can I load 3 separate strings using session.

    
asked by anonymous 05.07.2017 / 01:52

2 answers

4

Creating SESSIONS is quite simple, just do:

session_start(); //Inicia a sessão
//Seta as variáveis
$_SESSION['string1'] = 'Oi';
$_SESSION['string2'] = 'Olá';
$_SESSION['string3'] = 'Eu sou uma string';
    
05.07.2017 / 03:50
0

Daniel if these values are constants of the system create a file and within it define constants like this:

define (CONSTANT_NAME, 'value');

define (CONSTANT_NAME, 'value');

Then make an include in the pages you are going to use.

That's right in capital letters then use CONSTANT_NAME1 or CONSTANT_NAME2 in your script wherever you want! If the value of these variables is not constant use session!

    
05.07.2017 / 04:10