Need some help including a CURL function

I have a CURL function:

function sendPost($posturl,$params,$use_ssl){

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_POST,1);

  curl_setopt($ch, CURLOPT_POSTFIELDS,$params);

  if($use_ssl)

      $posturl = str_replace('http:','https:',$posturl);

  curl_setopt($ch, CURLOPT_URL,$posturl);

  if($use_ssl){

      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  }

  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

  $result = curl_exec($ch);

  curl_close ($ch);

  echo $result;

 

  $array = array();

  $pieces = explode('&',$result);

  foreach($pieces as $val){

      if($val){

        $temp = explode('=',$val);

        $array[$temp[0]]=$temp[1];

      }

  }

return $array;

}

I need to use it for the output of a form:

  public function actionmemberSignup()

  {

      $membersignup=new MemberSignupForm;

      if(isset($_POST['MemberSignupForm']))

      {

        $membersignup->attributes=$_POST['MemberSignupForm'];

        $posturl = 'xxxxxxxxxxxxxxxx';

       

        if($membersignup->validate())

        {

            $params = "action=user_create&account_id=xxxxxx&gateway_pass=xxxxxxxxxxxxxxxxx&user=$membersignup->loginname&pass=$membersignup->loginpw&email=$membersignup->email&first_name=$membersignup->fname&last_name=$membersignup->lname&address1=$membersignup->addr1&address2=$membersignup->addr2&city=$membersignup->city&state=$membersignup->state&zip=$membersignup->zip&country=$membersignup->country";

            $makeuser = sendPost($posturl,$params,true);

            Yii::app()->user->setFlash('membersignup','<br /><br /><center>Thankyou for joining . You now have access to all areas of our site.</center>');

            $this->refresh();

        }

      }

      $this->render('membersignup',array('membersignup'=>$membersignup));

  }

I am new to Yii and MVC frameworks in general and could use some insight as to how to do this.

What is your question? Is it about how to include the CURL function you defined? If so, you may define it as a class method, a global function or a static class method.

Yes it is about how to include the CURL function.  Could you assist me in how to define a global function in Yii?

Save it in a file and include it when needed, just like you usually do with PHP programming.  ;)

If you want to make your code more OOP, you may write a class and make this function a static method of that class. Then you can use Yii::import() method to include the class file.

OK, I included it in my MemberSignupForm.php model and I get a return code from the remote server but it also generates a Yii error:

session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/wildcams/public_html/includes/curl_connect.php:29)

Any insight?

Do you have an empty line outside of <?php ?> ?

I found my error.  I had an echo in the function.  Thanks very much for your assistance.  I look forward to becoming more proficient with theis great framework.