Username should be obtained by getting user name for effective UID. Using USERNAME or USER variables is not the right way (when you just "su" and not "su - " it keeps previous username):
id : uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=user_u:system_r:unconfined_t
./validate.php: [FAIL] You need to run this script as root
echo $USER: <name of user that did su>