code_junkie

Does using global create any overhead?

Nov 11th, 2011
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. function foo() {
  2. global $fu;
  3. global $bah;
  4. if (something()) {
  5. $fu->doSomething();
  6. } else {
  7. $bah->doSomething();
  8. }
  9. }
  10.  
  11. function bar() {
  12. if (something()) {
  13. global $fu;
  14. $fu->doSomething();
  15. } else {
  16. global $bah;
  17. $bah->doSomething();
  18. }
  19. }
  20.  
  21. function foo() {
  22. global $fu, $bah;
  23. if (something()) {
  24. $fu->doSomething();
  25. } else {
  26. $bah->doSomething();
  27. }
  28. }
  29.  
  30. function foo($fu, $bah) {
  31. if (something()) {
  32. $fu->doSomething();
  33. } else {
  34. $bah->doSomething();
  35. }
  36. }
Add Comment
Please, Sign In to add comment