Page 1 of 1

Making a resource?

Posted: Tue Oct 25, 2011 1:07 pm
by Eric!
Is it possible to make a new resource function in PHP? For example can I replace a fsockopen or fopen with a custom resource that does something else with the data passed to it? I can't seem to find much information on this. Perhaps I'm using the wrong terminology?

Should I be looking at building a streamWrapper?

Re: Making a resource?

Posted: Tue Oct 25, 2011 2:19 pm
by egg82
I'm not 100% sure about classes (never tried them myself) but if PHP is anything like C or C++ (which it is) then a class is what you're looking for

Re: Making a resource?

Posted: Tue Oct 25, 2011 6:19 pm
by Eric!
I don't think resources are the same as classes in php. http://php.net/manual/en/language.types.resource.php

"Special variable"? The example in the manual doesn't help me much.

Re: Making a resource?

Posted: Tue Oct 25, 2011 6:34 pm
by genix2011
hmm... seems like you'd have to code that directly into the Zend engine :)

Seriously, it depends what you want to do exactly, you could perhaps achieve this with the streamWrapper.

Greets.

Re: Making a resource?

Posted: Wed Oct 26, 2011 11:40 pm
by Eric!
I think a resource is a name for an external entry point to a compiled library. So streamwrapper it is.