$str='1234567890abcdefgh';
echo $str[0];
这个官方是怎么认定的啊?

解决方案 »

  1.   


    error_reporting(E_ALL);
    // Get the first character of a string
    $str = 'This is a test.';
    $first = $str[0];// Get the third character of a string
    $third = $str[2];// Get the last character of a string.
    $str = 'This is still a test.';
    $last = $str[strlen($str)-1]; // Modify the last character of a string
    $str = 'Look at the sea';
    $str[strlen($str)-1] = 'e';echo "first is: ${first}<br />";
    echo "third is: ${third}<br />";echo "last is: ${last}<br />";
    echo "str is: ${str}";
    ?>
      

  2.   

    好像从C语言开始,字符串数据就被视为多个单个字符组成的特殊数组了。比如'abc',就是由'a''b''c''\0'组成。
      

  3.   

    2楼正解。Php弱类, 并不是很严格的需要初始化变量的类型,会自动去识别转换