Usnig th URI class in library

#1
[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

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

#3
[eluser]Deathmanlp[/eluser]
Thanks waldmeister


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.