• 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

Alert message after submitting form in PHP

PHPExcel file download using AJAX call

Render the content of default_filter.php in Joomla front-end

Message: Set sys_temp_dir in your php.ini after installed composer

Prestashop webservice API creating cart rules

Symfony there are no commands defined in the "make" namespace

best way to store error messages in Laravel (session or variable)

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

Yii2: How do I debug console commands?

wp_remote_get() not passing authentication

Backend cannot be reached after Typo3 login screen

How do I upload a laravel project on cPanel shared hosting?

Laravel PackageManifest.php: Undefined index: name

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

Laravel Nova, route not found

About Contact Privacy policy Terms and conditions