Re: System errno in PHP
| From: | Ravi Menon | Date: | Fri, 22 Feb 2008 21:27:14 +0000 |
| Subject: | Re: System errno in PHP | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269915@lists.php.net to get a copy of this message | ||
Hi,
I also ran into the same issue with file and socket apis, and for now, I just
hack it like ( for linux 2.6 systems ):
class Errno
{
const EINTR = 4;
const EIO = 5;
const EINVAL = 22;
const ENODATA = 61;
const EBADMSG = 74;
const EOPNOTSUPP = 95;
const ECONNRESET = 104;
const ENOTCONN = 107;
const ETIMEDOUT = 110;
const EALREADY = 114;
const EINPROGRESS = 115;
// useful static methods that use posix_strerror()
// and socket_strerror() to return strings for logging purposes...
.
.
}
Clearly this is not portable, but I am betting that usually on the
same kernel releases, they
don't usually change these numbers around.
Having PHP expose these useful constants in a portable manner would be
a big plus.
Thanks,
Ravi
On Thu, Feb 21, 2008 at 9:04 AM, Richard Lynch <ceo@l-i-e.com> wrote:
> On Wed, February 20, 2008 2:56 am, Michal Maras wrote:
> > I have read http://php.net/fopen from top to bottom, but
> > I could not
> > find
> > how to get system error number.
> > With set_error_handler I can get string for example
> >
> > fopen(hmc_configuration.cfg)
> >
> > [function.fopen<http://ds63450.mspr.detemobil.de/%7Emmaras/HMC/function.fopen>]:
> > failed to open stream: Permission denied
> >
> > but I need integer number not string, because string error messages
> > depends
> > on locale setting.
> > Of course, I can test some conditions before fopen, but it is not
> > enough
> > for me.
>
> Put in a Feature Request to expose the error number from the OS, I
> guess...
>
> http://bugs.php.net/
>
> It *seems* like it ought to be reasonable enough to this naive user.
>
>
> --
> Some people have a "gift" link here.
> Know what I want?
> I want you to buy a CD from some indie artist.
> http://cdbaby.com/from/lynch
> Yeah, I get a buck. So?
>
> --
>
>
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>