Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3.  
  4. function doNotice() {
  5. if($a) echo "AH!";
  6. }
  7.  
  8. function doIsset() {
  9. if(isset($a)) echo "AH!";
  10. }
  11.  
  12. function doBoth() {
  13. if(isset($a) && $a) echo "AH!";
  14. }
  15.  
  16. function doEmpty() {
  17. if(!empty($a)) echo "AH!";
  18. }
  19.  
  20. $t = microtime(true);
  21. for($i = 0; $i < 1000000; $i++)
  22. doNotice();
  23. echo 'if($a): '.(microtime(true)-$t)."\n";
  24.  
  25. $t = microtime(true);
  26. for($i = 0; $i < 1000000; $i++)
  27. doIsset();
  28. echo 'isset($a): '.(microtime(true)-$t)."\n";
  29.  
  30. $t = microtime(true);
  31. for($i = 0; $i < 1000000; $i++)
  32. doBoth();
  33. echo 'isset($a) && $a: '.(microtime(true)-$t)."\n";
  34.  
  35.  
  36. $t = microtime(true);
  37. for($i = 0; $i < 1000000; $i++)
  38. doEmpty();
  39. echo 'empty: '.(microtime(true)-$t)."\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement