How to check if data is empty or whitespace only in PHP
问题 I have an input field that needs a username. The scenario is, how can i prevent user from providing whitespace or whitespaces in the that field? I already added required in the input field so i can prevent user from leaving it blank. <input type="text" name="username" required> but what if the user puts whitespace or as many whitespace as he can, is there any possible way i can detect this and throw error to the user? in my php file i already have if(empty($_POST['username'])){ echo "Username