更多实例
例子 1
使用带有不同正负数的 start 参数:<?phpecho substr("Hello world",10)."
";echo substr("Hello world",1)."
";echo substr("Hello world",3)."
";echo substr("Hello world",7)."
";echo substr("Hello world",-1)."
";echo substr("Hello world",-10)."
";echo substr("Hello world",-8)."
";echo substr("Hello world",-4)."
";?>
例子 2
使用带有不同正负数的 start 和 length 参数:<?phpecho substr("Hello world",0,10)."
";echo substr("Hello world",1,8)."
";echo substr("Hello world",0,5)."
";echo substr("Hello world",6,6)."
";echo substr("Hello world",0,-1)."
";echo substr("Hello world",-10,-2)."
";echo substr("Hello world",0,-6)."
";echo substr("Hello world",-2-3)."
";?>