Zend framework 如何在zend controller中调用自定义php函数?

Zend framework 如何在zend controller中调用自定义php函数?,zend-framework,zend-framework2,Zend Framework,Zend Framework2,如何在zend controller中调用简单的自定义php函数 class Ozone_IndexController extends Zend_Controller_Action { public function snetworkAction(){ } function curl_file_get_contents($url){ } } 如何在snetworkAction中调用curl_file_get_contents($url)函数你的问题肯定与ZF2无关

如何在zend controller中调用简单的自定义php函数

class Ozone_IndexController extends Zend_Controller_Action
{
   public function snetworkAction(){

   }
   function curl_file_get_contents($url){

   }
}

如何在snetworkAction中调用curl_file_get_contents($url)函数

你的问题肯定与ZF2无关。它实际上可以归结为OOP的基础知识

你为snetworkAction设定好路线了吗?如果是这样,那么调用另一个对象方法的操作的内容将是:

public function snetworkAction(){
    $this->curl_file_get_contents( 'http://someurl.com' );
}

private function curl_file_get_contents( $url ){
    ...
}
我强烈建议在深入研究ZF2之前先掌握基本知识。如果你没有掌握基本的知识,这将是一次令人沮丧的经历。这是一个非常独特的框架,虽然非常优秀,但会导致新手流血


祝你好运。你的问题肯定是ZF2不可知论。它实际上可以归结为OOP的基础知识

你为snetworkAction设定好路线了吗?如果是这样,那么调用另一个对象方法的操作的内容将是:

public function snetworkAction(){
    $this->curl_file_get_contents( 'http://someurl.com' );
}

private function curl_file_get_contents( $url ){
    ...
}
我强烈建议在深入研究ZF2之前先掌握基本知识。如果你没有掌握基本的知识,这将是一次令人沮丧的经历。这是一个非常独特的框架,虽然非常优秀,但会导致新手流血


祝你好运。你的问题肯定是ZF2不可知论。它实际上可以归结为OOP的基础知识

你为snetworkAction设定好路线了吗?如果是这样,那么调用另一个对象方法的操作的内容将是:

public function snetworkAction(){
    $this->curl_file_get_contents( 'http://someurl.com' );
}

private function curl_file_get_contents( $url ){
    ...
}
我强烈建议在深入研究ZF2之前先掌握基本知识。如果你没有掌握基本的知识,这将是一次令人沮丧的经历。这是一个非常独特的框架,虽然非常优秀,但会导致新手流血


祝你好运。你的问题肯定是ZF2不可知论。它实际上可以归结为OOP的基础知识

你为snetworkAction设定好路线了吗?如果是这样,那么调用另一个对象方法的操作的内容将是:

public function snetworkAction(){
    $this->curl_file_get_contents( 'http://someurl.com' );
}

private function curl_file_get_contents( $url ){
    ...
}
我强烈建议在深入研究ZF2之前先掌握基本知识。如果你没有掌握基本的知识,这将是一次令人沮丧的经历。这是一个非常独特的框架,虽然非常优秀,但会导致新手流血


祝你好运。你可以像这样调用curl\u file\u get\u contents($url)

$this->curl\u file\u get\u contents($url)


最好将函数定义为protected

您可以调用curl\u file\u get\u contents($url),如

$this->curl\u file\u get\u contents($url)


最好将函数定义为protected

您可以调用curl\u file\u get\u contents($url),如

$this->curl\u file\u get\u contents($url)


最好将函数定义为protected

您可以调用curl\u file\u get\u contents($url),如

$this->curl\u file\u get\u contents($url)

最好将函数定义为受保护