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 Build a Simple PHP Application Wrapping Up The Project Validating Contact Form Data

Robert Mews
Robert Mews
11,540 Points

Using the isset function vs. trim?

Why wouldn't we use the isset function rather than using the trim function? I'm not very clear on why trim is useful here? Maybe another example would help.

2 Answers

i think you missed something. isset() = this is a check function built into php example: if(isset($someVar)){ do something}; if something is set in any form run the code associated with it. trim() = is a function to remove spaces from the begin or end of a user submitted data field. example: " spaces in front and at the end " if the data in the quotes was submitted and you ran the trim function on the field it would remove the spaces from the begin and the end so it would read like "spaces in front and at the end".

they are used for different items trim removes spaces and htmlspecialchars converts special characters to html entities like & will be converted to & so they will be displayed properly. you can look them all up at http://php.net/manual/en/index.php

Juliette Tworsey
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Points

LOL...silly me.. I was thinking of the strpos command (...learning a lot of PHP syntax at once). I think that I posted this question in the wrong place.

Do they both accomplish the same thing?

Thanks again-