: This article mainly introduces the PHP string and Byte Conversion examples. if you are interested in the PHP Tutorial, refer to it. Refer: http://www.php230.com/1410667081.html
> 8 & 0xff); $ byt [2] = ($ val> 16 & 0xff); $ byt [3] = ($ val> 24 & 0xff ); return $ byt ;} /*** read an Integer type data from the specified position in the byte array * @ param $ bytes byte array * @ param $ position specified start position * @ return an Integer type data */publicstaticfunctionbytesToInteger ($ bytes, $ position) {$ val = 0; $ val = $ bytes [$ position + 3] & 0xff; $ val <= 8; $ val | = $ bytes [$ position + 2] & 0xff; $ val <= 8; $ val | = $ bytes [$ position + 1] & 0xff; $ Val <= 8; $ val | = $ bytes [$ position] & 0xff; return $ val ;} /*** convert a shor string to a byte array * @ param $ byt target byte array * @ param $ val the string to be converted **/publicstaticfunctionshortshorttobytes ($ val) {$ byt = array (); $ byt [0] = ($ val & 0xff); $ byt [1] = ($ val> 8 & 0xff ); return $ byt;}/*** reads data of the Short type from the specified position in the byte array. * @ Param $ bytes byte array * @ param $ position specifies the start position * @ return a Short type data */publicstaticfunctionbytesToShort ($ bytes, $ position) {$ val = 0; $ val = $ bytes [$ position + 1] & 0xFF; $ val = $ val <8; $ val | = $ bytes [$ position] & 0xFF; return $ val ;}}?>