title: Pass an object attribute by reference
body: <p>I have this php function to add an object to the database, but it is giving me some troubles to make it work. I'm pretty used to the java way, so i tried to follow the same pattern, and I'm getting an error message that says "Strict standards: Only variables should be passed by reference". 
  This is the code:</p>
  
  <pre><code>public function saveUser(User $user){
      $this-&gt;connection = DaoFactory::openConnection();
      $this-&gt;query = $this-&gt;connection-&gt;prepare($this-&gt;SAVE_QUERY);
  
      $this-&gt;query-&gt;bindParam(':name', $user-&gt;getName());
      $this-&gt;query-&gt;bindParam(':lastName', $user-&gt;getLastName());
      $this-&gt;query-&gt;bindParam(':age', $user-&gt;getAge());
      $this-&gt;query-&gt;bindParam('gender', $user-&gt;getGender());
      $this-&gt;query-&gt;bindParam(':email', $user-&gt;getEmail());
      $this-&gt;query-&gt;bindParam(':password', $user-&gt;getPassword());
  
      $this-&gt;query-&gt;execute();
      $this-&gt;connection = null;
  
  }
  </code></pre>
  
  <p>I've searched and i found that the object attribute should be placed in a variable to avoid this issue, but by doing so, the code gets very messy and complex.Example:</p>
  
  <pre><code>$name = $user-&gt;getName();
  $this-&gt;query-&gt;bindParam(':name',$name);
  </code></pre>
  
  <p>Is there any other way to solve this?</p>