Stream_Var
[ class tree: Stream_Var ] [ index: Stream_Var ] [ all elements ]

Source for file example_modes.php

Documentation is available at example_modes.php

  1. <?PHP
  2.     require_once 'Stream/Var.php';
  3.     stream_wrapper_register"var""Stream_Var" );
  4.  
  5.     $varname 'var://_GET/foo';
  6.  
  7.     echo    "_GET variables:<pre>";
  8.     print_r$_GET );
  9.     echo    "</pre>";
  10.     
  11.     echo    "<strong>open '$varname' with mode 'r':</strong><br>";
  12.     echo    "This should fail, as the variable does not exist.<br>";
  13.     $fp fopen($varname"r");
  14.     fclose($fp);
  15.     
  16.     echo    "<br>_GET variables:<pre>";
  17.     print_r$_GET );
  18.     echo    "</pre>";
  19.  
  20.     echo    "<br><strong>open '$varname' with mode 'w':</strong><br>";
  21.     echo    "This should work, as the 'w' creates the variable.<br>";
  22.     $fp fopen($varname"w");
  23.     echo    "writing data to the variable.<br>";
  24.     fwrite($fp"This is a");
  25.     fclose($fp);
  26.  
  27.     echo    "<br>_GET variables:<pre>";
  28.     print_r$_GET );
  29.     echo    "</pre>";
  30.  
  31.     echo    "<br><strong>open '$varname' with mode 'a+':</strong><br>";
  32.     echo    "This will append data to a variable or create.<br>";
  33.     $fp fopen($varname"a+");
  34.     echo    "writing data to the variable.<br>";
  35.     fwrite($fp" Test");
  36.     fseek($fp0SEEK_SET);
  37.     $data fgets($fp,200);
  38.     echo    "read data: ".$data."<br>";
  39.     fclose($fp);
  40.  
  41.     echo    "<br>_GET variables:<pre>";
  42.     print_r$_GET );
  43.     echo    "</pre>";
  44.  
  45.     echo    "<br><strong>open '$varname' with mode 'x':</strong><br>";
  46.     echo    "This should fail, as the variable does exist and 'x' wants to create a new file.<br>";
  47.     $fp fopen($varname"x");
  48.     fclose($fp);
  49.  
  50.     echo    "<br>_GET variables:<pre>";
  51.     print_r$_GET );
  52.     echo    "</pre>";
  53. ?>

Documentation generated on Mon, 11 Mar 2019 15:32:46 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.