The Swoole\Buffer class

- « Swoole\Atomic::sub

- Swoole\Buffer::append »

- PHP Manual
- Swoole
- The Swoole\Buffer class

# The Swoole\Buffer class

(PECL swoole >= 1.9.0)

## Introduction

## Class synopsis

class Swoole\Buffer {
/* Methods */
public append(string `$data`): int
public clear(): void
public __destruct(): void
public expand(int `$size`): int
public read(int `$offset`, int `$length`): string
public recycle(): void
public substr(int `$offset`, int `$length` = ?, bool `$remove` = ?): string
public __toString(): string
public write(int `$offset`, string `$data`): void
}

## Table of Contents

- Swoole\Buffer::append — Append the string or binary data at the end of the memory buffer and return the new size of memory allocated.
- Swoole\Buffer::clear — Reset the memory buffer.
- Swoole\Buffer::__construct — Fixed size memory blocks allocation.
- Swoole\Buffer::__destruct — Destruct the Swoole memory buffer.
- Swoole\Buffer::expand — Expand the size of memory buffer.
- Swoole\Buffer::read — Read data from the memory buffer based on offset and length.
- Swoole\Buffer::recycle — Release the memory to OS which is not used by the memory buffer.
- Swoole\Buffer::substr — Read data from the memory buffer based on offset and length. Or remove data from the memory buffer.
- Swoole\Buffer::__toString — Get the string value of the memory buffer.
- Swoole\Buffer::write — Write data to the memory buffer. The memory allocated for the buffer will not be changed.