I know many will call this micro optimizing, yes it is that but it is also good to know things like this. Now my question, in my first example below you will see I have a variable set that contains a mysql query then I have another line that runs a function with the above variables mysql query. In my 2nd example I do it all in 1 line, I assume there is no real speed gain but possibly this would help lower memory usage?
//example 1
$sql= 'UPDATE users SET setting_online=0 WHERE user_id=' .$_SESSION['user_id'];
Database::executeQuery($sql);
//example 2
Database::executeQuery('UPDATE users SET setting_online=0 WHERE user_id=' .$_SESSION['user_id']);
Possibly yes, but those 40 or 50 bytes are not going to matter, ever.
But reducing the number of variables is good for an entirely different reason: it reduces the amount of state you as a programmer have to keep track of in order to follow the program – and that makes your job easier and thus the code more maintainable.