How to define multiple empty variables in PHP This style:
$variable1 = '';
$variable2 = '';
$variable3 = '';
Or like that:
$variable1 = $variable2 = $variable 3 = '';
Which method is faster from server point of view?
Cheers
How to define multiple empty variables in PHP This style:
$variable1 = '';
$variable2 = '';
$variable3 = '';
Or like that:
$variable1 = $variable2 = $variable 3 = '';
Which method is faster from server point of view?
Cheers
This type of variable defining:
$var1 = '';
$var2 = '';
$var3 = '';
$var4 = '';
$var5 = '';
took 112 milliseconds for 100000 repetitions.
While this :
$var1 = $var2 = $var3 = $var4 = $var5 = '';
took only 60 milliseconds.
Next test, only with two variables:
$var1 = '';
$var2 = '';
vs
$var1 = $var2 = '';
Numbers are 76ms vs 48ms for 100000.
Maybe is not too much, but why not to define variables in optimal way.
Thanks
Well, Here I found some already answered questions which may help you:
How can I measure the speed of code written in PHP?
Tracking the script execution time in PHP
http://www.developerfusion.com/code/2058/determine-execution-time-in-php/
Basically, the trick is using microtime()
.
Have a look at them and see if any of the methods mentioned can measure to that precision as you require.
Hope it helps!