Welcome Guest, Not a member yet? Register   Sign In
Creating Core System Classes - I did some thing wrong?
#1

[eluser]low battery[/eluser]
Hi, Thank you all!
Code:
class MY_Exceptions extends CI_Exceptions {
    
  function __construct() {
    parent::CI_Exceptions();
  }
    
  /**
   * Show some things
   *
   *
   *
   * @access  private
   * @param  string  the heading
   * @param  string  the message
   * @param  string  the template name
   * @return  string
   */
  function show_message($heading, $message, $template = 'message_general') {
    echo 'Message is: {$heading},{$message}';
  }
}

I has been save it to "application/libraries" path, I type the follow code in my controller:
Code:
$this->Exceptions->show_message('the heading', 'the messages');

But the PHP engine tell me :
Cannot redeclare class CI_Exceptions in D:\fleaphp-apmxe\htdocs\SPS\system\libraries\Exceptions.php on line 27

I did some thing wrong?
#2

[eluser]low battery[/eluser]
I just wanna create a class, Could send some messages to the customer.
Sure, I wanna add something images,colours,etc.. Sad

And also i has add follow code in autoload.php
Code:
$autoload['libraries'] = array('Exceptions');
#3

[eluser]srisa[/eluser]
[quote author="low battery" date="1230074794"]
I has been save it to "application/libraries" path, I type the follow code in my controller:
[/quote]
With what name did you save the file?
#4

[eluser]low battery[/eluser]
The file name is MY_Exceptions.php. Thank you all!
#5

[eluser]therealmaloy[/eluser]
low battery

the problem i think is your constructor

function __construct() {
parent::CI_Exceptions();
}

this constructor likely tells you to initialize/construct a base class which is already existing in the form of CI_Exceptions class.

to correct the problem, you can use either of the following:

to extend from a parent CI Classes, it is advised to use the name of your derived class

function My_Exceptions() {
parent::CI_Exceptions();
}

to extend from the base class, i think you have to use the parent::__construct

function __construct() {
parent::__construct();
}
#6

[eluser]low battery[/eluser]
hm..I'm trying, Thank you!




Theme © iAndrew 2016 - Forum software by © MyBB