Re: System errno in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

 Thank you for answer, but I do not understand.
 How can I use this class Errno after unsuccessful fopen?
 I want to get the number, for example 13 if there is not enough permissions
to open file.
It is not problem for me that script will be no portable, it is
only for AIX.

By

On 22/02/2008, Ravi Menon <jravimenon@xxxxxxxxx> wrote:
>
> 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@xxxxxxxxx> 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
> >
> >
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux