php 5.2.2 增加了 Substr的溢出检测不知道 那个大大 有以前版本的 substr的实现代码??谢谢

解决方案 »

  1.   

    substr将字符串 string 的第 start 位起的字符串取出 length 个字符。若 start 为负数,则从字符串尾端算起。若可省略的参数 length 存在,但为负数,则表示取到倒数第 length 个字符,若length超出范围,返回就为空了。---这个PHP的问题,不是你的问题
      

  2.   

    我用 5.2.3
    <?
    echo substr('111',-6) === false;
    ?>
    substr的结果是返回 false 手册里是这么写的,看来直到5.2.2才真正实现
    http://cn.php.net/substr----------------------------If length is given and is positive, the string returned will contain at most length characters beginning from start (depending on the length of string). If string is 【less than or equal to start characters long】, 【FALSE】 will be returned. 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 a position beyond this truncation, an empty string will be returned. 例 2292. Using a negative length<?php
    $rest = substr("abcdef", 0, -1);  // returns "abcde"
    $rest = substr("abcdef", 2, -1);  // returns "cde"
    $rest = substr("abcdef", 4, -4);  // returns ""
    $rest = substr("abcdef", -3, -1); // returns "de"
    ?>
      

  3.   

    en .,,
    手册上说的是 返回 false的。。
      

  4.   

    php  5.1.x  php -r 'echo substr("111",-6) ;'
    111