substr sbustring slice

substr( start [ , length ] )
start 若 < 0,则从右起计数
start 若 < 0且绝对值超过字符串长度的,视为0
length 若 ≤ 0,返回空字符串
length 若 ≤ 0,返回空字符串若不指定,则默认截取到末尾

substring( start [ , end ] )
end 若 > 字符串长度,则自动指定为字符串末尾
end 若不指定,则自动指定为字符串末尾
任一参数 < 0,或为 NaN,则将其视为0;
若 start > end,则两者交换数值;

slice( start [ , end ] )
任一参数 < 0,从字符串末尾往前倒推
不会发生交换,而是返回空字符串

原文地址:https://www.cnblogs.com/wangdapeng/p/7079568.html