dongxiatuo9827 2013-02-20 20:30
浏览 30
已采纳

在PHP中使用OOP时在方法中使用函数

I need to know something about OOP in PHP.
Can I put functions in class methods or no ? Like this:

<?php
class test {
   function test1() {

      // do something

      function test1_1() {
         // something else
      }

   }
}
?>

And use it in this way: $test->test1->test1_1();

  • 写回答

4条回答 默认 最新

  • duanliaoyu8419 2013-02-20 20:33
    关注

    No you cannot. That would just create a new function in the global namespace and will give you errors of trying to redeclare the function when called multiple times.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?