• 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

Trying to iterate over a mongodb cursor twice - failing

With doctrine ODM, can I embed many subdocuments in a main document?

How to use React Router with Laravel?

Show rotation of tweets using current day of month

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

How to install php yaml on CentOs?

How to run a shell as root from php (apache)

Confirm Leave on External Links in Wordpress

Explode not working properly with dash

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

Alert message after submitting form in PHP

sort() not affecting original array while inside foreach loop

Exception thrown during the rendering of a template("Parameter "id" for route "url" must match "[^/]++" ("" given) to generate a corresponding URL.")

curl returning 301 error after migrating to https

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

About Contact Privacy policy Terms and conditions