This function takes a string argument as input
The first thing he does is check the recursive base argument. We will return to this
If the base case fails, it then checks to see if the first character matches the last character with this code:
if (substr($string,0,1) == substr($string,(strlen($string) - 1),1))
If this matches, then the function recursively calls itself again, but this time with the removal of the first and last characters this is done using this line
return Palindrome(substr($string,1,strlen($string) -2));
If the first character does not match the last character, the function automatically outputs to html "STRING IS NOT A PALINDROME via echo
Now back to the base case, which I mentioned earlier, if the function successfully matches and deletes the first and last characters until one or more characters remain, then the line was confirmed as a palindrome, and this echo points to this line.
If you need help with recursion, let me know, I will send a link for the tutorial
source share