title: function in PHP not returning result
body: <p>I have a simple data retrieval PHP file from Mysql and encodes in JSON string. The code below returns the result as expected</p>
  
  <pre><code>&lt;?php
  require 'dbconnection.php';
  
  
  $tablename = $_GET["tabname"];
  
  $sql = "SELECT * FROM ". $tablename ;
  
  if (!mysqli_query($conn,$sql))
  {
      echo("Error description: " . mysqli_error($con));
  } else {
      $res = mysqli_query($conn,$sql);
  } 
  
  $result = array();
  
  
  while($row = mysqli_fetch_array($res)){
  array_push($result,
  array('_id'=&gt;$row[0],
        'course_name'=&gt;$row[1],
        'address'=&gt;$row[2],
        'city'=&gt;$row[3],
        'state'=&gt;$row[4],
        'zipcode'=&gt;$row[5],
        'phone'=&gt;$row[6]));
  }   
  
  
  echo json_encode(array("result"=&gt;$result));
  $conn-&gt;close();
  </code></pre>
  
  <p>?> </p>
  
  <p>Sample Result...</p>
  
  <pre><code>{"result":[{"_id":"1","course_name":"Quail Valley","address":"12565 NW Aerts Rd.","city":"Banks","state":"OR","zipcode":"97106","phone":"5033244444"},...]}
  </code></pre>
  
  <p>My goal is to use the variable that was passed to PHP and based on it's name call function. I can't seem to figure out what I'm doing wrong!</p>
  
  <pre><code>&lt;?php
  require 'dbconnection.php';
  
  
  $tablename = $_GET["tabname"];
  
  function Course() {
      $sql = "SELECT * FROM ". $tablename ;
  
      if (!mysqli_query($conn,$sql))
      {
          echo("Error description: " . mysqli_error($conn));
      } else {
      $res = mysqli_query($conn,$sql);
      }
  
      $results = array();
  
      while($row = mysqli_fetch_array($res)){
      array_push($results,
          array('_id'=&gt;$row[0],
            'course_name'=&gt;$row[1],
            'address'=&gt;$row[2],
            'city'=&gt;$row[3],
            'state'=&gt;$row[4],
            'zipcode'=&gt;$row[5],
            'phone'=&gt;$row[6]));
      }
          return $results;
  }
  
  $result = call_user_func(Course()); 
  // OR... $result = call_user_func($tablename());
  echo json_encode(array("result"=&gt;$result));
  $conn-&gt;close();
  </code></pre>
  
  <p>?> </p>
  
  <p>Here is the output...</p>
  
  <pre><code>Error description: {"result":null}
  </code></pre>