php - What does trim() actually do in this validation check? -


i'm reading php book, below phrase mean?

to eliminate leading , trailing whitespace, use trim() function.

it's being used in following condition check:

if(!empty(trim($_post['username'])) && !empty(trim($_post['email']))) { } 

empty checking make sure username , email variable not empty

! signifies not

here empty http://php.net/manual/en/function.empty.php

a variable considered empty if not exist or if value equals false. empty() not generate warning if variable not exist.

trim

removes whitespace beginning , end of stringstrip whitespace (or other characters) beginning , end of string

http://php.net/manual/en/function.trim.php

so if have string " user " trim(" user ") returns "user"


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -