Reverse a String in PHP Using strrev

Reverse a String in PHP Using strrev. A PHP program to print the reverse string. Using this program to reverse the string using strrev function. The term “string” refers to a group of characters. PHP supports a number of data types, including strings. Alphanumeric characters are allowed in string variables. When you declare a variable and assign string characters to it, you get a string.

<?php 
$string = "welcome to inlarn";
echo "Reverse string of $string is " .strrev ( $string );
?>

 

Output:

Reverse string of welcome to inlarn is nralni ot emoclew

String in Php

The term “string” refers to a group of characters. PHP supports a number of data types, including strings. Alphanumeric characters are allowed in string variables. When you generate a string, you can use it straight with the echo statement in PHP. There are four possible ways to specify a string literal: There are two types of quotations: single and double. Syntax can be found here.

Strrev in Php

The strrev() function is a PHP built-in function for reversing a string. It will also reverse a number if it is given a number rather than a string. Value of the Return: The reversed string or number is returned by the strrev() function. To reverse the given string, use the strrev() method.