My library name is numbertowords and it's in library folder and i want to call it in view page..How do i call?? i called like this
<?php
$this->load->library('numbertowords');
?>
<?php
echo $this->numbertowords->convert_number($row['billtotal']);
echo" Rupees Only"
?>
</h3>
I am getting error like this
A PHP Error was encountered Severity: Notice
Message: Undefined property: CI_Loader::$numbertowords
Filename: Inventory/Bill_Print1.php
Line Number: 233
Backtrace:
File: C:\xampp\htdocs\Yuva3\application\views\Inventory\Bill_Print1.php
Line: 233
Function: _error_handler
File: C:\xampp\htdocs\Yuva3\application\controllers\TipUp_Loan.php
Line: 74
Function: view
File: C:\xampp\htdocs\Yuva3\index.php
Line: 315
Function: require_once
Fatal error: Call to a member function convert_number() on null in C:\xampp\htdocs\Yuva3\application\views\Inventory\Bill_Print1.php on line 233
A PHP Error was encountered
Severity: Error
Message: Call to a member function convert_number() on null
Filename: Inventory/Bill_Print1.php
Line Number: 233
Backtrace:
changed my library file name from numbertowords To Numbertowords..
<?php
$this->load->library('Numbertowords');
?>
<?php
echo $this->numbertowords->convert_number($row['billtotal']);
echo" Rupees Only"
?>
</h3>
The problem is that $this
is not what you think it is.
What you're expecting it to be is a reference to the controller instance (sometimes called the "CI Super object"), but it is actually an instance of the loader ($this->load
).
The library should be loaded in the controller and convert_number()
used to modify data there before it is passed to the view.