PHP 8.4.0 RC4 available for testing

chop

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

choprtrim() のエイリアス

説明

この関数は次の関数のエイリアスです。 rtrim().

注意

注意:

chop() は、文字列の末尾の文字を削除する Perl の chop()関数とは異なります。

add a note

User Contributed Notes 2 notes

up
61
Kubo2
9 years ago
Rather use rtrim(). Usage of chop() is not very clear nor consistent for people reading the code after you.
up
9
JumpIfBelow
9 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