• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Could not decode a text frame as UTF-8.

phpjavascriptsocketswebsocket


PHP Snippet 1:

socket_write($socket, encode($answer));
function encode($text) {
    $b1 = 0x80 | (0x1 & 0x0f);
    $length = strlen($text);
    if ($length <= 125)
        $header = pack('CC', $b1, $length);
    elseif($length > 125 && $length < 65536)
        $header = pack('CCn', $b1, 126, $length);
    elseif($length >= 65536)
        $header = pack('CCNN', $b1, 127, $length);
    
    return $header.$text;
}

Related Snippets

Redirect to previous page with php

Remove product downloads section in woocommerce email notifications

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

I want to display a sweetalert after the inserting of data in my database

Xdebug 3 not showing in phpinfo on m1 Monterey

Uncaught TypeError: Cannot read property 'length' of null when retrieving tags from wp

How to downgrade or install a specific version of Composer?

How to identify whether webp image is static or animated?

Edit product hook WooCommerce

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

Results page in other window

I need to link Google Sheet with my Laravel

Return new collection without modifying original collection

How to get unique slug to same post-title for other time too?

protect my blog content

About Contact Privacy policy Terms and conditions