Modest Module: perror (exec error codes)

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

 



I've written my first external Module for PHP: perror

It provides functionality I've always felt was "missing" in PHP.

I'm particularly interested in feedback from anybody who has written
PHP extensions of their own -- I'm sure there's room for improvement
in my very rusty C skills!

Here's why I wrote it.  Consider this:
<?php
  exec("ls /root", $output, $error);
  if ($error) die("OS Error: $error");
  echo nl2br(implode('', $output));
?>

Wouldn't it be nice if PHP "knew" the error message that went with
Error code number 1?

Well, install this 'perror' module, and PHP does know :-)

As a special bonus, since it was pretty much the exact same thing, I
threw in the codes for "signals" as well.

A quick phpize and compile and a php.ini change, and you're set!

I can't promise no problems, but it's pretty dang simple, really, so
should be pretty safe.  And you can always comment out php.ini
extension setting pretty quickly if it causes problems.

See sample output (live, actually) and download the source:

http://www.l-i-e.com/perror/

PS
*HUGE* thanks to the folks on PHP-Dev who put up with my bumbling
through the compiling process for an extension on a shared server!

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
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