title: PHP Trim function not removing whitespaces
body: <p>I'm doing some tests with learning purpose. I have a PHP script in which I used some functions to see how they work:</p>
  
  <ul>
  <li><p>First I used isset to make sure a var exist</p></li>
  <li><p>Then <code>empty</code> to make sure if a var has some value</p></li>
  <li><p>Finally I used <code>trim</code> to remove whitespaces</p></li>
  </ul>
  
  <p>After some testing I realized that trim function is not working properly.
  For example I can still write <code>whitespaceCHARwhitespace</code>, then I used <code>strlen</code> function and I get a 3 as a result. What's wrong with my script?</p>
  
  <p>Btw I would like to know how acceptable is this form validation I would like to avoid some sqlinjection.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>&lt;span&gt;&lt;?php echo $msg;?&gt;&lt;/span&gt;
  &lt;form method="POST"&gt;
      &lt;label for="name" class="white-headers"&gt;NAME&lt;/label&gt;
      &lt;input type="text" name="name" id="name" class="form-control"&gt;
      &lt;label for="last_name" class="white-headers"&gt;LAST NAME&lt;/label&gt;
      &lt;input type="text" name="last_name" id="last_name" class="form-control"&gt;
      &lt;input type="submit" class="btn btn-success" name="submit"&gt;
  &lt;/form&gt;
  
  
     $msg="";
    if(isset($_POST["submit"])){
     $name = $_POST["name"];
    $last_name = $_POST["last_name"];
  if(!empty(trim($name)) &amp;&amp; !empty(trim($last_name))){
      $name_len=strlen($name);
      $last_name_len=strlen($name);
      $msg="&lt;div class='alert alert-success'&gt;
      both fields are set and have some value name =".$name." with ".$name_len." chars and last_name =".$last_name."
      with ".$last_name_len. "chars&lt;/div&gt;";
  }
  else{
      $msg="&lt;div class='alert alert-danger'&gt;
      both fields are set but one or both are empty name =".$name." and last_name =".$last_name."&lt;/div&gt;";
  }
  }
  </code></pre>