PHP 8.5.0 Beta 1 available for testing

chop

(PHP 4, PHP 5, PHP 7, PHP 8)

choprtrim() 的别名

说明

此函数是该函数的别名:rtrim()

注释

注意:

chop() 与 Perl 的 chop() 函数有所不同,它会删除字符串的最后一个字符。

添加备注

用户贡献的备注 2 notes

up
62
Kubo2
10 years ago
Rather use rtrim(). Usage of chop() is not very clear nor consistent for people reading the code after you.
up
12
JumpIfBelow
10 years ago
If you are searching for a function that does the same trick as chop in PERL, then you should just do the following code:
<?php
$str
= substr($str, 0, -1);
?>

The question is: why isn't chop() an alias of the code above, rather than something which will trap developpers?
To Top