<?php
function reverseString($str) {
return strrev($str);
}
$inputString = "Hello, World!";
$reversedString = reverseString($inputString);
echo "Original String: $inputString<br>";
echo "Reversed String: $reversedString";
?>
- The script defines a function
reverseString
that uses thestrrev
function to reverse a given string. - The function takes a string as input and returns its reversed version.
- The script then calls the function with a sample string (
$inputString
) and prints the original and reversed strings.