title: Stop executing a script?
body: <p>I call a php function from ajax (addContent):</p>
  
  <pre><code>protected $output = array('success'=&gt;0, 'message'=&gt;'There was an error, please try again.');
  
  public function addContent()
  {
      $imgName = $this-&gt;doSomething();
      $this-&gt;doSomethingElse();
  
      //save imageName to DB
      $this-&gt;output['success'] = 1;
      return $output;
  }
  
  private function doSomething()
  {
      if($imageOk){
         return $imageName;
      }
      else
      {
         $this-&gt;output['message'] = 'bad response';
         //how to return output?
      }
  
  }
  </code></pre>
  
  <p>I have made the methods simple for illustrative purposes.</p>
  
  <p>If the method 'doSomething()' has an output of bad response, how can I send this back from the addContent method to ajax? If the output is bad, I want to exit the script and not continue executing doSomethingElse().</p>