PHP strrev Function | Reverse a String in PHP

PHP strrev is an inbuilt function in PHP which reverses the input string. It takes a string in the parameter and returns the reverse of that string. In this article, we will discuss the PHP strrev Function. Also, we will discuss a few examples of using it.


strrev ($input_string);


The function expects one parameter. The input string which you want to reverse is passed as the parameter.

Return Value

The function returns the reverse of the input string.

Input: strrev('Hello World!')
Output: !dlroW olleH
PHP strrev Function



    $inputString = 'Hello World!';
    $reverseString = strrev($inputString);

In the above example, the function returns the reverse of the string.

!dlroW olleH


You can read more about PHP strrev on the Official Documentation of PHP. Additionally, you can read more about PHP String Functions on Concatly.

Spread the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *