PHP substr() function
ringa_lee
ringa_lee 2017-05-24 11:30:51
0
2
806

How to understand PHP substr() function usage: If the start parameter is a negative number and length is less than or equal to start, then length is 0.
This sentence

ringa_lee
ringa_lee

ringa_lee

reply all(2)
迷茫

Use the php function, write a demo to test it

substr('abcdefg', -4, -2) and substr('abcdefg', -4, -6)

为情所困

If a negative length is provided, length characters at the end of the string will be omitted (if start is a negative number, it will be counted from the end of the string). If start is not in this text, FALSE will be returned.
Reference: http://php.net/manual/zh/func...

Look at sbbstr('abcdefg', -4, -3), so the character with length 3 at the end of the character will be omitted. The actual intercepted string is abcd;sbbstr('abcdefg', -4, -3),所以该字符末尾长度为3的字符会被省略真正被截取的字符串为abcd;
同理sbbstr('abcdefg', -4, -5),当length小于等于start时,包括下标为-4之后的字符都被省略了,所以截取的字符串也是空,所以说length0Similarly to sbbstr('abcdefg', -4, -5), when length is less than or equal to start , including characters after the subscript -4 are omitted, so the intercepted string is also empty, so length is 0

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template