• PHP Help PHP Coding
  • [RESOLVED] Trying to call a function within a function, that are both in the same class

Trying to call a function within a function, that are both in the same class...

so the layout is like this

class myclass {

function myfunc() {
myprivfunc($param1, $param2, $param3)

}

private function myprivfunc($param1, $param2, $param3) {

}

}

My question is this. To call a function that is within a class, can i just call it like this

myprivfunc($param1, $param2, $param3)

or is there more to it then that ???

does the function have to be made before or after the function is called ???

If your not understanding. here is my code...

function send_message(){
			$headers .= "To : <".$this->to."> \n";
			$headers .= "From: ".$this->from;


			foreach ($this->message as $key => $value) {
				 $comments .= $key ." : ".$value."\n"; 
			}

			if(!empty($this->email) && !empty($this->subject) && !empty($comments)) {



					$this->final_message  .= 'From: '.$this->from."\n".'Email: '.$this->senders_email."\n".'Subject: '.$this->subject."\n\n";

					$this->final_message .= "Message! \n".$comments;

				} 
				else
				{

					return $outcome = "There were empty fields";
				}

			internal_send($this->email, $this->subject, $this->final_message, $headers);   // THIS IS LINE 90

	}

and here is internal_send

private function internal_send($email, $subject, $message, $headers){
			if (@mail($email, $subject, $message, $headers)){
					return $outcome = "Your mail has been successfully sent!";

			} else {

				return $outcome = "Your mail was not successfully sent. Please check the form fields. Otherwise there may
							be errors on the page!"; 
			}
	}	

but i keep getting this error

Fatal error: Call to undefined function internal_send() in /home/igvdev/public_html/empire/system/content/mail_form.php on line 90

    function myfunc() {
    $this->myprivfunc($param1, $param2, $param3)
    } 
    

    perhaps?

      damnit I knew that. I knew there was something missing. thanks

        Write a Reply...