The same string is not equal

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.