title: Returning data from controller - Codeigniter
body: <p>I am trying to return data to my variable $item_id but the variable returns empty. Am i not returning the data the right way ?? </p>
  
  <p>item_id should return "Alert" which is coming from the index function in serverMonitor.php. </p>
  
  <p>Please advice. Thank you</p>
  
  <p><strong>Items.php</strong></p>
  
  <pre><code> function rest_state()
    {
       $id = 1;
       $item_id =  $this-&gt;pass_to_res($id);
       return $item_id //this should return "Alert"
  
    }
  
  
  
  function pass_to_res($id)
     {
        $url = "https://example.com/serverMonitor?id=$id";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
        $result = curl_exec($ch);
        curl_close ($ch);
        return $result;
     }
  </code></pre>
  
  <p><strong>serverMonitor.php</strong></p>
  
  <pre><code> function index() {
  
          $id = htmlentities($_GET['id']);
          $word = "Alert";
          return $word;
      }
  </code></pre>