String length problems

Source: Internet
Author: User
String length problem vardump print a string
String (14) "00107042012"
How is the length of the obtained string 14?
It must be 11 numbers!
Why?


Reply to discussion (solution)

Your string contains the first three special characters (+ BOM)

 


Let's look at the two outputs.


The ascii code 239,187,191 of the three special characters is the ef bb bf of the BOM header.
 ';$str = '00107042012';$str1 = '00107042012';echo 'str:
';for($i=0,$len=strlen($str);$i<$len;$i++){ echo ord(substr($str,$i,1)).'
';}echo '
str1:
';for($i=0,$len=strlen($str1);$i<$len;$i++){ echo ord(substr($str1,$i,1)).'
';}?>


str:2391871914848494855485250484950str1:4848494855485250484950


You can remove it using a program.
 

Your string contains the first three special characters (+ BOM)

 


Let's look at the two outputs.


The ascii code 239,187,191 of the three special characters is the ef bb bf of the BOM header.
 ';$str = '00107042012';$str1 = '00107042012';echo 'str:
';for($i=0,$len=strlen($str);$i<$len;$i++){ echo ord(substr($str,$i,1)).'
';}echo '
str1:
';for($i=0,$len=strlen($str1);$i<$len;$i++){ echo ord(substr($str1,$i,1)).'
';}?>


str:2391871914848494855485250484950str1:4848494855485250484950


You can remove it using a program.
 



The problem has been solved. thanks to the moderator for replying ~ The next time you get it, convert it to an ascii code output.

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.