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 9124141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:30:24+00:00 2026-06-17T06:30:24+00:00

Hi has anyone any experience using Phil Sturgeons RESTFUL libraries for codeigniter. I’ve decided

  • 0

Hi has anyone any experience using Phil Sturgeons RESTFUL libraries for codeigniter. I’ve decided to create a web service for our database in order to supply access to the database from multiple applications. The website is currently developed in Codeigniter therefore it was a simple solution to use the rest API libraries.

The problem I have is that I am trying to return specific errors in the event of a problem.

At the moment I am purposely returning an error like so:

require(APPPATH . 'libraries/REST_Controller.php');

class Settings_api extends REST_Controller {

    function settings_get()
    {
        $this->response(NULL, 404);
    }
}

If I access the url directly then I am just receiving a blank page, I can return a message if I replace the ‘NULL’ with a message but there is nothing to say its a 404 error whereas If I call the page via php using the following

$user = json_decode(file_get_contents('http://www.example.co.uk/api/settings_api/settings/'));

echo $user;

then it shows the following line

Message: file_get_contents(http://www.example.co.uk/api/settings_api/settings/) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 

In both instances I would like to return a 404 error along with a message I provide. Is this possible and if so could you point me in the right direction.

Thanks

  • 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-17T06:30:25+00:00Added an answer on June 17, 2026 at 6:30 am

    The error message being generated by PHP, as far as I know, there’s nothing you can do about this (other than using the @ operator, which I do NOT recommend). So, your only option is to manually check file_get_content()‘s return value:

    $response = file_get_contents('http://...');
    
    if ($response === false) {
        // return whatever you feel is appropriate
    } else {
        $user = json_decode($response);
        echo $user;
    }
    

    EDIT
    Found this answer here on Stackoverflow which is what you are looking for.

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

Sidebar

Related Questions

Has anyone had any experience using Adobe Air to create BitTorrent application? Is there
Has anyone had any experience of talking between an iSeries (using IBM's Websphere MQ)
I need help with using VQmod, if anyone has any experience with, I'd appreciate
Has anyone had any experience writing a web control (in either ASP.net, or javascript/HTML/CSS),
Has anyone got any experience using google analytics and coremetrics in the same campaign
Has anyone had any experience of using the Google Client API to authorise against
Has anyone had any experience with using the STEP and EXPRESS formats in a
Has anyone used or have any experience of using the curl-java binding package. I
has anyone had any experience using BING maps on the iphone/ipad? We have an
Hi has anyone had any experience using both Stripes and Play and can compare

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.