0

I have a php object that is working fine. I'm now trying to get one public function to call a private one and I can't get it working...

  // Join - Headline & About Me
  public function updateHeadlineAboutMe($joinHeadline, $joinAboutMe) {

    // Profanity Audit Member Text
    $prof_headline = profanityAudit($joinHeadline);
    $prof_aboutme = profanityAudit($joinAboutMe);


    echo $prof_headline;
    echo $prof_aboutme;

   // other code here...    

}


  // Profanity Audit of Member Text
  private function profanityAudit($auditText) {
    return('ok');
  }

I'm just trying to get the private function to return a value so I know its being called successfully. This function will be used (by many functions) to compare text to a list of swear words in a table to see of the text needs manual reviewing...

What should I try to get this working?

thankyou very much...

2 Answers 2

2

If the functions are inside an object, you will need to use $this.

$prof_headline = $this->profanityAudit($joinHeadline);
Sign up to request clarification or add additional context in comments.

Comments

1

If both functions are in the same class, you missed $this.

$prof_headline = $this->profanityAudit($joinHeadline);

The other line as well.

If they are not in the same class, you won't be able to call a private function, because it is the idea of private functions: not to be called from outside.

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.