+ 1
How to use and change a global boolean variable inside if condition PHP
8 Respostas
+ 18
if ($GLOBALS['foo'] === 2) {
// do something
}
+ 18
Mostafa Mousavi Yes. But to be correct:
$foo = 2;
Using global variables is a bad practice though.
+ 15
Something like this:
if (true) {
$GLOBALS['foo'] = 2 * $GLOBALS['foo'];
}
if ($GLOBALS['foo'] === 2) {
// do something
}
+ 3
Igor Makarsky tnx
+ 2
Mostafa Mousavi
Can you elaborate more on the question? do you have a code here in SoloLearn for a review? I would try to help if you can show me link to your code.
+ 1
Ipang it was a code that i m coding for a telegram bot and its huge 😅 and it dosent make sense if is paste all of it
0
Igor Makarsky i meant inside if condition not changing due to condition
0
Igor Makarsky another question
Is declaring it for the first time like normal variables?
I mean like ex :
foo = 2;