Okay, here's a newbie theoretical question. In other words, something I've come across which I have no idea why I would ever use but I'm curious about it anyway!
If i add a number to a variable, the answer to this becomes the new value of that variable, and if I subtracted a number from the variable, it would then subtract it from the new value rather than the original value.
For example:
<?php
$variable1 = 2;
$variable1 += 4; echo $variable1."<br />";
$variable1 -= 1; echo $variable1;
?>
However, when I use either a ceil or floor function to a float, the rounded value doesn't behave like the previous example. Instead, when I do a mathematical function to the variable, it takes it from the original value rather than the new ceil-ed or floor-ed value.
For example:
<?php
$variable1 = 3.14;
echo ceil($variable1)."<br />";
$variable1 += 1; echo $variable1
?>
Is the reason for this something to do with the fact that ceil and floor aren't pure mathematical functions like adding or squaring? If I wanted to in the previous example retain the value of the ceil (4) when adding to its value, how would I do this?
PS: Brownie points to anyone who can come up with a reason as to why I would do this in a real project.