• 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

cakephp save drag and drop list order to database

Make certain characters of a word from string bold

Target Individual Form Instance/Counter Inside A PHP While Loop

Eloquent insert id with sequence next value

How to extract price from given url using Xpath?

Converting IPv6 to IPv4 address in PHP

Entity provider not working in security.yml php symfony3.4 ({"code":401,"message":"bad credentials"}.)

Getting output of MS stored procedure on php call

Display a success custom notice after Placing an Order in WooCommerce

How to read laravel_session cookies saved in cookie memory of browser in client side?

Mysqli multi query error

How can I format this number correctly using PHP?

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

get attribute from class not working php 7

Symfony redirect if already loggedin from login page

About Contact Privacy policy Terms and conditions