• 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

How update php.ini on a Mac OS X Mojave?

Laravel 5 issue with wherePivot

PHP Imap , php 7.4.3 on mac osx catalina

PHP mail function is sending blank message body

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

Laravel phpunit test failing authorization

Store / Website Column in Magento 2 Admin Grid - Custom Module

How to Install Composer Require doctrine/dbal

Can I use a WooCommerce function without any WooCommerce page?

php echo xml documents with header

Laravel websockets AWS EC2 - Connection failed

Class AppHttpControllersUserController Does Not Exist

Not able to override collapsible.js in magento 2

How to execute sql code based on fetch array

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

About Contact Privacy policy Terms and conditions