调用Class方法中的函数? [英] Calling a function within a Class method?

查看:229
本文介绍了调用Class方法中的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在想办法这样做,但我不太确定如何。

I have been trying to figure out how to go about doing this but I am not quite sure how.

这是一个我想要做的例子:

Here is an example of what I am trying to do:

class test {
     public newTest(){
          function bigTest(){
               //Big Test Here
          }
          function smallTest(){
               //Small Test Here
          }
     }
     public scoreTest(){
          //Scoring code here;
     }
}

这是我遇到问题的部分,我要调用bigTest()?

Here is the part I am having problems with, how do I call bigTest()?

推荐答案

尝试这个:

class test {
     public function newTest(){
          $this->bigTest();
          $this->smallTest();
     }

     private function bigTest(){
          //Big Test Here
     }

     private function smallTest(){
          //Small Test Here
     }

     public function scoreTest(){
          //Scoring code here;
     }
}

$testObject = new test();

$testObject->newTest();

$testObject->scoreTest();

这篇关于调用Class方法中的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆