News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Jonnay's Blog:
An issue with PHP's error handling
January 19, 2006 @ 07:35:42

On Jonnay's blog today (at jonnay.net), there's this new post talking about an issue with the way PHP handles certain errors.

With all my REST and AJAX explorations, I have run into what I consider to be a fundamental issue in PHP's error handling: when the parser or interpreter runs into an error it will always return HTTP status code 200.

Semantically this is wrong. Here is the way it should be, at least in my eyes:

If PHP runs into a non-recoverable error (E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR and E_COMPILE_WARNING; i.e. where the error cannot be trapped by set_error_handler()), it should spit out a HTTP status code of 500 (Internal Server Error), and depending on the setting of the ini directive display_errors display the error text, or conversely the standard Internal Server Error page.

He meditation (a set of classes that aid in REST APIs).

0 comments voice your opinion now!
issue with error handling return HTTP 200 issue with error handling return HTTP 200


Jaanus' Blog:
How to retrieve remote files in your web apps and still be friends with the server
January 18, 2006 @ 07:19:36

In this post on Jaanus' blog today, they show how you can grab remote files from a server and still "remain friends" with the server.

It often happens that when you're building a web page or app, you may want to include some content from a remote server. Say that it's some statistic figure that the remote outputs as HTML or TXT and you then want to retrieve it and either do something with it or directly display as part of your own page. And you're working in PHP.

PHP provides a fancy way of opening and including files directly over HTTP, which they call "URL wrappers". As tempting as it may seem, in the long run doing remote opens with URL wrappers is not the best practice. So here's what I came up with when needing to do this kind of caching thing in my own scenarios. It requires you have the cURL module installed and that the webserver can read and write from /tmp.

They provide the short script that does the work inside a function (easy to drop into a class), and grabs the remote file, and pulls down to /tmp for the script to use. It even allows you to specify a timeout for the file, forcing the script to grab a new copy every so often...

1 comment voice your opinion now!
retrieve remote files friends with server curl timeout retrieve remote files friends with server curl timeout



Community Events





Don't see your event here?
Let us know!


laravel unittest release library introduction testing code community list framework opinion developer series configure language wordpress threedevsandamaybe install podcast interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework