PHP code example of shufflingpixels / php-io

1. Go to this page and download the library: Download shufflingpixels/php-io library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

shufflingpixels / php-io example snippets




use Shufflingpixels\IO\BinaryReader;

$reader = BinaryReader::string("\x34\x12\x80\xff");

$a = $reader->readUInt16LE(); // 0x1234 => 4660
$b = $reader->readInt8();     // -128
$c = $reader->readInt8();     // -1



use Shufflingpixels\IO\Buffer;
use Shufflingpixels\IO\SeekMode;

$buffer = new Buffer('abcdef');

$buffer->seek(2);                  // position = 2
$buffer->write('XY');              // data becomes: abXYef
$buffer->seek(-2, SeekMode::END);  // position near end

$tail = $buffer->read(2);          // "ef"



use Shufflingpixels\IO\File;
use Shufflingpixels\IO\FileMode;

$file = File::open('example.bin', FileMode::RW);

$file->write("ABC");
$file->seek(0);

$bytes = $file->read(3); // "ABC"

$file->close();