views:

86

answers:

2

In PHP 5.2.3, "fdopen" was used to read/write to a file descriptor that's opened by another application.

fdopen(<fileDescriptorId>,"rw");  //It worked fine with PHP 5.2.3

After upgrading PHP to 5.3.2, it's throwing "undefined reference to 'fdopen' function".

Please suggest whats the replacement for this in PHP 5.3.2 or any workaround.

A: 

The fdopen is related to C language. There is no such function in PHP. I think you have mis-typed the PHP's fopen function, right? Correct me. Thanks

Sarfraz
Yes,I also searched for "fdopen" in PHP 5.2.3 API but couldn't find this.But it didn't report any error with PHP 5.2.3 [double-checked it and didn't mistype] might be as VolkerK suggested some other extension might have been built with that version.
Naga Kiran
+1  A: 

Could this fdopen() of yours have been provided by a custom php extension?
On a linux/unix server

function fdopen($id, $mode) {
  return fopen("/proc/self/fd/".(int)$id, $mode);
}

might work.

edit: see http://linux.die.net/man/5/proc

VolkerK
Thanks. PHP-cgi binary is invoked by a webserver that runs in a jail directory(sandbox).So,it doesn't have access to the file (socket) path ("/proc/self/fd/" . (int)$id,$mode) directly.Is there any way in PHP to read/write given only file descriptor number [assuming if the file path is not known as its not accessible in this case].Please let me know your comments.
Naga Kiran