Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8754859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:43:28+00:00 2026-06-13T13:43:28+00:00

Possible Duplicate: Throw a NotImplementedError in PHP? When writing base-classes, I often develop gradually,

  • 0

Possible Duplicate:
Throw a NotImplementedError in PHP?

When writing base-classes, I often develop gradually, and only build what I need (Or, what I am testing). Yet I like my interface to be balanced. For every getter a setter. When implmenting CRUD, even when right now, I need only the R, I’d rather write the stubs for CUD laready.

I want these to throw some Not Implemented Exception. How can I raise such errors or exceptions?

For example:

class Resource {
  /**
   * get Issues a GET-request to Online, fetch with $this::$id
   * @returns $this
   */
  protected function get() {
    if ($this->id) {
      $attributes = http_build_query(array("id" => $this->id));
      $url = "{$this->url}?{$attributes}";
      $options = array_merge(array('method' => 'GET'));
      $response = _http_request($url, $options);
      $this->parse($response);
    }
    return $this;
  }

  /**
   * post Place a new object on Online
   *
   * @param $attributes ....
   * @returns Source $this
   */
  protected function post($attributes = array()) {
    throw new NotImplementedError();
  }

  /**
   * put Updates an object on Online
   *
   * @param $attributes ....
   * @returns $this
   */
  protected function put($attributes = array()) {
    throw new NotImplementedError();
  }

  /**
   * delete Removes an object from Online, selected by $this::$id.
   * @returns $this
   */
  protected function delete() {
    throw new NotImplementedError();
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:43:29+00:00Added an answer on June 13, 2026 at 1:43 pm

    Have a look at this previous answer: Throw a NotImplementedError in PHP?

    Very simply put, one doesn’t exist in PHP, but you can easily create your own by extending an existing Exception. The previous answer suggests using BadMethodCallException to do this:

    class NotImplementedException extends BadMethodCallException
    {}
    

    Then you can throw a NotImplementedException within your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: 'or' statement on instruction fail: how to throw a new exception?
Possible Duplicate: How do I make a request using HTTP basic authentication with PHP
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Throw an error in a MySQL trigger I have a table definition
Possible Duplicate: difference between throw and throw new Exception() I'm a programmer working on
Possible Duplicate: throwing exceptions out of a destructor In C++ we should never throw
Possible Duplicate: Foreach can throw an InvalidCastException? Consider the following block of code public
Possible Duplicate: How to find out where a function is defined? included php file
Possible Duplicate: PHP short circuit lazy evaluation, where is it in the php.net manual?
Possible Duplicate: What is the difference between throw and throw with arg of caught

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.