(no version information, might be only in CVS)
php_stream_cast() attempts to
convert stream into a
resource indicated by
castas. If ret is
NULL, the stream is queried to find out if such a conversion
is possible, without actually performing the conversion
(however, some internal stream state *might* be changed in
this case). If flags is set
to REPORT_ERRORS, an error
message will be displayed is there is an error during
conversion.
注: This function returns SUCCESS for success or FAILURE for failure. Be warned that you must explicitly compare the return value with SUCCESS or FAILURE because of the underlying values of those constants. A simple boolean expression will not be interpreted as you intended.
表格 43-1. Resource types for
castas
In addition to the basic resource types above, the
conversion process can be altered by using the following
flags by using the OR operator to combine the resource type
with one or more of the following values:
表格 43-2. Resource types for
castas
注: If your system supports fopencookie() (systems using glibc 2 or later), the streams API will always be able to synthesize an ANSI FILE* pointer over any stream. While this is tremendously useful for passing any PHP stream to any third-party libraries, such behaviour is not portable. You are requested to consider the portability implications before distributing you extension. If the fopencookie synthesis is not desireable, you should query the stream to see if it naturally supports FILE* by using php_stream_is()
注: If you ask a socket based stream for a FILE*, the streams API will use fdopen() to create it for you. Be warned that doing do may cause data that was buffered in the streams layer to be lost if you intermix streams API calls with ANSI stdio calls.
See also php_stream_is() and php_stream_can_cast().