PHP: Changing a variable

The word 'variable' itself implies that it can be changed. And indeed, with time, the value of a variable inside the program can change.


$greeting = 'Father!';

$greeting = 'Mother!';

The name hasn't changed, but the information inside is different. We should note that it's not required to declare variables in PHP. A variable is declared at the moment of its initial use in the program instead.

Variables is a powerful and at the same time dangerous thing. We can't be sure what value is stored in the variable without analyzing the preceeding code. That's exactly what developers do when they are trying to find out why their program is not working, or not working the way it's supposed to, in the debugging process.


There is a variable with value 'Brienna' in the code. Redefine the value of the variable and assign to it the same string in reversed order.


  • Variable - a way to store information and give it a name to be reused in code later.

If you got stuck and don't know what to do, you can ask a question in our huge and friendly community