If length is given and is positive, the string returned will contain at most length characters beginning fromstart (depending on the length of string).
If length is given and is negative, then that many characters will be omitted from the end of string (after the start position has been calculated when a start is negative). If start denotes the position of this truncation or beyond, false will be returned.
If length is given and is 0, FALSE or NULL an empty string will be returned.
If length is omitted, the substring starting from start until the end of the string will be returned.
length如果提供了正数的 length,返回的字符串将从 start 处开始最多包括 length 个字符(取决于 string的长度)。
如果提供了负数的 length,那么 string 末尾处的许多字符将会被漏掉(若 start 是负数则从字符串尾部算起)。如果 start 不在这段文本中,那么将返回一个空字符串。
如果提供了值为 0,FALSE 或 NULL 的 length,那么将返回一个空字符串。
如果没有提供 length,返回的子字符串将从 start 位置开始直到字符串结尾。
原文返回的是false,中文的返回的是空字符串。
$rest = substr("abcdef", 4, -4); // returns false
运行后返回的是false,而不是返回空字符串!另外,个人感觉这段翻译也需要稍作调整!
--
您收到此邮件是因为您订阅了Google网上论坛中的“phpdoc-zh”论坛。
要退订此论坛并停止接收此论坛的电子邮件,请发送电子邮件到phpdoc-zh+...@googlegroups.com。
要查看更多选项,请访问https://groups.google.com/d/optout。