0

How can i call simple custom php function in zend controller ?

class Ozone_IndexController extends Zend_Controller_Action
{
   public function snetworkAction(){

   }
   function curl_file_get_contents($url){

   }
}

how i can call curl_file_get_contents($url) function inside snetworkAction

2 Answers 2

3

Your question is definitely ZF2-agnostic. It really boils down to OOP basics.

Have you set up your route for snetworkAction? If so, then the contents of your action, to call that other object method, would simply be:

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

private function curl_file_get_contents( $url ){
    ...
}

I would strongly recommend getting a grasp on basics before going deep into ZF2. It's really going to be a frustrating experience if you don't have the fundamentals down pat. It's a very unique framework, and while excellent, will cause neophytes to bleed!

Good luck man.

Sign up to request clarification or add additional context in comments.

Comments

0

you can call curl_file_get_contents($url) like

$this->curl_file_get_contents($url);

it is better to define function as protected

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.