If the strings are not the same, the ip address and port are collected from a page. $ ip and $ duankou are collected and cannot be used. However, manual input can be used.
The two strings have different lengths but the encoding is the same. what should I do?
$ B is valid, $ a is invalid,
$ A = "tcp: //". $ ip. ":". $ duankou; $ B = "tcp: // 77.81.105.147: 7808"; echo $ ."
"; 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" equal ";} else {echo" not equal ";}
Output:
// Character tcp: // 77.81.105.147: 7808tcp: // 77.81.105.147: 7808 // encoded ASCIIASCII // length: 4224 // result range
Reply to discussion (solution)
Var_dump ($ a, $ B, $ encode, $ encodes );
Post result
Preferably
Echo base64_encode (serialize (array ($ a, $ B, $ encode, $ encodes )));
Post result
There are invisible empty characters in the collected data. try ip and port trim ().
Preferably
Echo base64_encode (serialize (array ($ a, $ B, $ encode, $ encodes )));
Post result
Result
YTo0OntpOjA7UzoyNDoidGNwOi8vNzcuODEuMTA1LjE0Nzo3ODA4IjtpOjE7Uzo0MjoidGNwOi8vPHRkPjc3LjgxLjEwNS4xNDc8L3RkPjo8dGQ+NzgwODwvdGQ+IjtpOjI7Uzo1OiJBU0NJSSI7aTozO1M6NToiQVNDSUkiO30=
There are invisible empty characters in the collected data. try ip and port trim ().
Trim () is over. it's still the same.
$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"}
The reason is obvious, right?
In fact, you can view the source code of the web page in the browser.
I have neglected the problem. thank you.