变量作用域

所有声明的变量都局部作用于声明它们的方法:

  1. namespace Test;
  2. class MyClass
  3. {
  4. public function someMethod1()
  5. {
  6. int a = 1, b = 2;
  7. return a + b;
  8. }
  9. public function someMethod2()
  10. {
  11. int a = 3, b = 4;
  12. return a + b;
  13. }
  14. }