PHP Developer Question: Download Questions PDF
How you can remove leading and trailing spaces from user input values in PHP?
Answer:
If you are taking input values from users with a Web form, users may enter extra spaces at the beginning and/or the end of the input values. You should always use the trim() function to remove those extra spaces as shown in this PHP script:
<?php
$name = $_REQUEST("name");
$name = trim($name);
# $name is ready to be used...
?>
<?php
$name = $_REQUEST("name");
$name = trim($name);
# $name is ready to be used...
?>
Download PHP Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
How you can remove the new line character from the end of a text line in PHP? | How to get number of characters in a String? |