时间:2021-07-01 10:21:17 帮助过:22人阅读
$a="tcp://".$ip.":".$duankou;$b="tcp://77.81.105.147:7808";echo $a."
";echo $b."
"; $encode = mb_detect_encoding($a, array("ASCII","UTF-8","GB2312","GBK","BIG5")); $encodes= mb_detect_encoding($b, array("ASCII","UTF-8","GB2312","GBK","BIG5")); echo $encode."
"; echo $encodes."
"; $changdu1= strlen($a); $changdu2= strlen($b); echo $changdu1."
"; echo $changdu2;if($a==$b){echo "相等";}else{echo "不等";}
//字符tcp://77.81.105.147:7808tcp://77.81.105.147:7808//编码ASCIIASCII//长度4224//结果不等
var_dump($a, $b, $encode, $encodes);
贴出结果
最好是
echo base64_encode(serialize(array($a, $b, $encode, $encodes)));
贴出结果
采集的数据里有不可见的空字符吧,把ip和port trim()一下试试
最好是
echo base64_encode(serialize(array($a, $b, $encode, $encodes)));
贴出结果
YTo0OntpOjA7UzoyNDoidGNwOi8vNzcuODEuMTA1LjE0Nzo3ODA4IjtpOjE7Uzo0MjoidGNwOi8vPHRkPjc3LjgxLjEwNS4xNDc8L3RkPjo8dGQ+NzgwODwvdGQ+IjtpOjI7Uzo1OiJBU0NJSSI7aTozO1M6NToiQVNDSUkiO30=
采集的数据里有不可见的空字符吧,把ip和port trim()一下试试
$s = 'YTo0OntpOjA7UzoyNDoidGNwOi8vNzcuODEuMTA1LjE0Nzo3ODA4IjtpOjE7Uzo0MjoidGNwOi8vPHRkPjc3LjgxLjEwNS4xNDc8L3RkPjo8dGQ+NzgwODwvdGQ+IjtpOjI7Uzo1OiJBU0NJSSI7aTozO1M6NToiQVNDSUkiO30=';$a = unserialize(base64_decode($s));var_dump($a);
array(4) { [0]=> string(24) "tcp://77.81.105.147:7808" [1]=> string(42) "tcp://77.81.105.147 :7808 " [2]=> string(5) "ASCII" [3]=> string(5) "ASCII"}
原来问题在这,我疏忽了,多谢了