Read the submitted value with the null coalescing operator, trim it, and escape it before displaying it. strrev() reverses a byte string; for full Unicode grapheme handling, additional Unicode-aware processing is needed.
echo \"<form name=f1 method=post action=''>
<input type=text name=t1><input type=submit value='Submit'></form>\";
$t1=trim($_POST['t1'] ?? ''); // Collect the submitted string
if(strlen($t1) > 1 ){ // If the length of the string is more than 1
echo \"Welcome $t1<br>
Your name in reverse : \".strrev($t1);
}
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.