Removing White-Spaces trim()
$ username = trim ($ _POST ['username ' ]);
rtrim()
Remove trailing spaces from a string
ltrim()
Remove leading spaces from a string
Special characters addslashes()
$ username = addslashes ($ _POST ['username ' );
use stripslashes()
to return the username to it's previous format
Convert String into array
$ usernames = explode (': ' , $ colon_separated_names );
use join()
/ implode()
to convert array into string
$ length = strlen ($ username );
$ strUpper = strtoupper ($ string );
use strtolower()
to convert string to LowerCase
Convert the first character of "hello" to uppercase
echo ucfirst ("hello world! " );
Convert the first character of each word to uppercase
echo ucwords ("hello world " );
echo nl2br ("List: \n 1- first options \n 2- second options " );
nl2br
stands for New Line To <br>
// Input Sanitization To Avoid SQL Injection And XSS .....
$ username = filter_var ($ _POST ['username ' ], FILTER_SANITIZE_STRING );
$ email = filter_var ($ _POST ['email ' ], FILTER_SANITIZE_EMAIL );
$ password = filter_var ($ _POST ['password ' ], FILTER_SANITIZE_STRING );
$ password = password_hash ($ password , PASSWORD_DEFAULT );