CodeIgniter Forums
Usnig th URI class in library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Usnig th URI class in library (/thread-33741.html)



Usnig th URI class in library - El Forum - 09-07-2010

[eluser]Deathmanlp[/eluser]
When I try to use the URI class from a library I get a undefined property error

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Class Articles_list_lib
{
  function __construct ()
  {
    $CI=null;
    $this->CI =& get_instance();
  }
  
  function show_errors ($errors)
  {  
    foreach ($errors as $error)
    {
      echo $error."<br/>";      
    }
  }

  function list_links ($links)
  {
    foreach ($links as $link)
    {
      echo $link."<br/>";
    }
  }
  function list_pages ($n_pages)
  {
    $start=0;
    $pages= array();
    for ($i=1;$i<=$n_pages;$i++)
    {
      $pages["page".$i]=anchor ("blog/index/".$start, $i);
      $start+=20;
    }
    $current_page=$this->uri->segment(3); // line 35
    
    
  }
    
}


Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Articles_list_lib::$uri

Filename: libraries/Articles_list_lib.php

Line Number: 35



Usnig th URI class in library - El Forum - 09-07-2010

[eluser]davidbehler[/eluser]
Code:
$current_page=$this->CI->uri->segment(3); // line 35



Usnig th URI class in library - El Forum - 09-07-2010

[eluser]Deathmanlp[/eluser]
Thanks waldmeister