Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Tajemnicze znaki
Dominator
post
Post #1





Grupa: Zarejestrowani
Postów: 565
Pomógł: 15
Dołączył: 11.10.2010

Ostrzeżenie: (20%)
X----


Witam
Podczas przeglądania skryptów na githubie natknąłem się na takie coś:

  1. function mc_status($host,$port='25565') {
  2. $timeInit = microtime();
  3. // TODO: implement a way to store data (memcached or MySQL?) - please don't overload target server
  4. $fp = fsockopen($host,$port,$errno,$errstr,$timeout=10);
  5. if(!$fp) die($errstr.$errno);
  6. else {
  7. fputs($fp, "\xFE"); // xFE - get information about server
  8. $response = '';
  9.  
  10. while(!feof($fp)) $response .= fgets($fp);
  11. fclose($fp);
  12. $timeEnd = microtime();
  13.  
  14. $response = str_replace("\x00", "", $response); // remove NULL
  15.  
  16. //$response = explode("\xFF", $response); // xFF - data start (old version, prior to 1.0?)
  17. $response = explode("\xFF\x16", $response); // data start
  18.  
  19. $response = $response[1]; // chop off all before xFF (could be done with regex actually)
  20.  
  21. //echo(dechex(ord($response[0])));
  22. $response = explode("\xA7", $response); // xA7 - delimiter
  23.  
  24. $timeDiff = $timeEnd-$timeInit;
  25. $response[] = $timeDiff < 0 ? 0 : $timeDiff;
  26. }
  27. return $response;
  28. }


Może mi ktoś wytłumaczyć te linijki?

  1. $response = str_replace("\x00", "", $response); // remove NULL
  2. //$response = explode("\xFF", $response); // xFF - data start (old version, prior to 1.0?)
  3. $response = explode("\xFF\x16", $response); // data start
Go to the top of the page
+Quote Post

Posty w temacie
- Dominator   [PHP] Tajemnicze znaki   25.01.2014, 11:42:48
- - Kshyhoo   Czytaj.   25.01.2014, 12:05:22
- - Dominator   Przeczytałem i jakoś nadal tego nie rozumiem.   25.01.2014, 12:25:22
- - Szymas   Jest to zapis znaku z tablicy ASCII.   27.01.2014, 07:56:58
- - Crozin   W PHP brakuje normalnego typu byte/char, który poz...   27.01.2014, 08:22:03


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 01:29