• 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

Reload parent page after submit in iframe

Changing font color in javascript

How to create a individual template for page or post in custom plugin?

How Can I Do LIMIT 1, 2 In WP_Query

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

PHPExcel_IOFactory::createWriter causes wrong behaviour

Laravel SQL query midnight time not showing

Limit of log line written to Apache Errorlog from mod php error_log

PHP echo values of all sub keys [duplicate]

php script to delete files older than 24 hrs, deletes all files

Laravel 5.1 xmlHttpRequest AJAX POST TokenMismatchException

PHP: Print caught exception like Xdebug

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

how to fix Service provider class not found when using repository?

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

About Contact Privacy policy Terms and conditions