title: How to make PDO query work inside a function
body: <p>I am try to make an PDO sql inside function but it doesn't work. got no response from it. it works when not using function. my purpose is to make my code small. anyone can shed a light. thanks.</p>
  
  <pre><code>function Test() {
  
      $get_name = $smt-&gt;prepare("SELECT * FROM customer WHERE id = '1'");
      $get_name-&gt;execute();
  
      foreach ($get_name as $temp) {
          $name = $temp['name'];
          $address = $temp['address'];
          $phone = $temp['phone'];
          $page = $temp['page'];
      }
  
      eval("\$page = \"$page\";");
      echo $page;
  
      eval("\$page = \"$page\";");
      echo $page;
  
  }
  
  Test();
  </code></pre>