Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Ben Os
Ben Os
20,008 Points

"To make sure that a required fields contains more than white-space, which function would you use? (It's trim... Why?)

Hi, a few days ago I had the question:

"To make sure that a required fields contains more than white-space, which function would you use?

The answer is the trim function.

Why is it the trim function? IIANW, this function trims content output (by content I mean strings\nums). If so, why is it the answer to the question?

Thanks.

1 Answer

Per Karlsson
Per Karlsson
12,683 Points

Hi,

You have the answer in the question:

"To make sure that a required fields contains more than white-space"

The trim function trims white space so one could not simply add five spaces in the field and it would be accepted. You would have to add a character (or another symbol). That's why it's the answer.

Hope that helps!

~Per

Ben Os
Ben Os
20,008 Points

So, if I understand correct, it trims the white spaces and thus (if the field is required) make ALL OTHER characters which are not white-space a must.

I didn't make the association between the required to that; You clarification helped me and you saved me some time reviewing the vid. Thanks!