I'm fairly new to PHP and I have a question regarding variable assignment. I'm trying to figure out if it's possible to assign the result of an expression to a variable in PHP.
I'm currently working on a project where I need to perform some calculations, and I thought it would be neat if I could directly assign the result of those calculations to a variable. I've tried searching online and looking through the PHP documentation, but I couldn't find a clear answer.
For example, let's say I have an expression like:
$result = 2 + 2;
Is it possible to assign the value of that expression (4) directly to the variable $result? Or do I have to separately calculate the value and then assign it?
I hope my question makes sense. I would greatly appreciate any insight or guidance you can provide on this matter. Thank you in advance for your help!