In the first example, if a variable is used only once, then it makes no sense to make the variable in the first place, just immediately respond to the results of the statements, there is no need for a variable.
In the second example, PHP has something called copy-on-write. This means that if you have two variables pointing to the same thing, they both simply point to one bit of memory. That is, until one of the variables is written, then a copy will be made, and a change will be made for this copy.
source share