What is practical uses of stream_wrapper_register in php? -


I am a new learner in php. And I found the 'stream_wrapper_register' function in the php document. Here's the link.

Can someone help me understand the exact use of this function in projects? I could not find any real time for this.

Here is an example, how to use data from the variable function that reads only from the file (Method image FPDF class by 'replaced' method by MemImage ).

  is required ('fpdf.php'); // Stream handler class for reading from global variable class VariableStream {var $ varname; Var $ position; Function stream_open ($ path, $ mode, $ option, and $ positions opened) {$ url = parse_url ($ path); $ This- & gt; Varna = $ url ['host']; If (! Isset ($ globals [$ this- & varname])) {trigger_error ('global variable'. $ This-> varname. 'Does not exist', E_USER_WARNING); return false; } $ This- & gt; Condition = 0; Back true; } Function_stream_read ($ count) {$ ret = substr ($ global [$ this- & gt; varname], $ this- & gt; position, $ count); $ This- & gt; Position + = strlen ($ ret); Return $ ret; } Function_stream_eof () {return $ this-> Status & gt; = Strlen ($ global [$ this-> varnish]); } Function_ stream_tel () {return $ this-> Event; } Function stream_sec ($ offset, where from) {if ($ where == SEEK_SET) {$ this- & gt; Position = $ offset; Back true; } return false; } Function_ stream_state () {return array (); }} Class PDF_MemImage FPDF {function PDF_MemImage ($ Orientation = 'P', $ unit = 'MM', $ format = 'A4') extends {$ this-> FPDF ($ Orientation, $ unit, $ format); // Register var Stream Protocol stream_wrapper_register ('var', 'VariableStream'); } Display the image contained in the memImage ($ data, $ x = zero, $ y = zero, $ w = 0, $ h = 0, $ link = '') {// $ $ $ $ im = 'img'} Md5 ($ data); $ Global [$ v] = $ data; $ A = getimagesize ('var: //'.$v); If (! $ A) $ this- & gt; Error ('Invalid Image Data'); $ Type = substrust (strust ($ a ['mime'], '/'), 1); $ This- & gt; Image ('var: //'. $ V, $ x, $ y, $ w, $ h, $ type, $ link); Not set ($ global [$ V]); } Display the GDim image associated with GDImage ($ im, $ x = null, $ y = null, $ w = 0, $ h = 0, $ link = '') {// $ im ob_start (); Imagepng ($ im); $ Data = ob_get_clean (); $ This- & gt; Mem image ($ data, $ x, $ y, $ w, $ h, $ link); }}    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -