How to call own library in view page
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:xampphtdocsYuva3applicationviewsInventoryBill_Print1.php
Line: 233
Function: _error_handler
File: C:xampphtdocsYuva3applicationcontrollersTipUp_Loan.php
Line: 74
Function: view
File: C:xampphtdocsYuva3index.php
Line: 315
Function: require_once
Fatal error: Call to a member function convert_number() on null in C:xampphtdocsYuva3applicationviewsInventoryBill_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:
php codeigniter libraries
add a comment |
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:xampphtdocsYuva3applicationviewsInventoryBill_Print1.php
Line: 233
Function: _error_handler
File: C:xampphtdocsYuva3applicationcontrollersTipUp_Loan.php
Line: 74
Function: view
File: C:xampphtdocsYuva3index.php
Line: 315
Function: require_once
Fatal error: Call to a member function convert_number() on null in C:xampphtdocsYuva3applicationviewsInventoryBill_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:
php codeigniter libraries
it is not a good practice to call library in view, you should call the library in your controller and pass the converted number to view
– TIGER
Nov 24 '18 at 6:47
Possible duplicate of codeigniter - loading a library from a view?
– TIGER
Nov 24 '18 at 6:47
okey..how do i call the function in view page..??
– dhara
Nov 24 '18 at 6:49
Include a copy of your library
– Alex
Nov 24 '18 at 8:33
didn't understand@Alex
– dhara
Nov 24 '18 at 8:56
add a comment |
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:xampphtdocsYuva3applicationviewsInventoryBill_Print1.php
Line: 233
Function: _error_handler
File: C:xampphtdocsYuva3applicationcontrollersTipUp_Loan.php
Line: 74
Function: view
File: C:xampphtdocsYuva3index.php
Line: 315
Function: require_once
Fatal error: Call to a member function convert_number() on null in C:xampphtdocsYuva3applicationviewsInventoryBill_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:
php codeigniter libraries
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:xampphtdocsYuva3applicationviewsInventoryBill_Print1.php
Line: 233
Function: _error_handler
File: C:xampphtdocsYuva3applicationcontrollersTipUp_Loan.php
Line: 74
Function: view
File: C:xampphtdocsYuva3index.php
Line: 315
Function: require_once
Fatal error: Call to a member function convert_number() on null in C:xampphtdocsYuva3applicationviewsInventoryBill_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:
php codeigniter libraries
php codeigniter libraries
edited Nov 24 '18 at 10:29
Mohammad
15.4k123461
15.4k123461
asked Nov 24 '18 at 6:38
dharadhara
20314
20314
it is not a good practice to call library in view, you should call the library in your controller and pass the converted number to view
– TIGER
Nov 24 '18 at 6:47
Possible duplicate of codeigniter - loading a library from a view?
– TIGER
Nov 24 '18 at 6:47
okey..how do i call the function in view page..??
– dhara
Nov 24 '18 at 6:49
Include a copy of your library
– Alex
Nov 24 '18 at 8:33
didn't understand@Alex
– dhara
Nov 24 '18 at 8:56
add a comment |
it is not a good practice to call library in view, you should call the library in your controller and pass the converted number to view
– TIGER
Nov 24 '18 at 6:47
Possible duplicate of codeigniter - loading a library from a view?
– TIGER
Nov 24 '18 at 6:47
okey..how do i call the function in view page..??
– dhara
Nov 24 '18 at 6:49
Include a copy of your library
– Alex
Nov 24 '18 at 8:33
didn't understand@Alex
– dhara
Nov 24 '18 at 8:56
it is not a good practice to call library in view, you should call the library in your controller and pass the converted number to view
– TIGER
Nov 24 '18 at 6:47
it is not a good practice to call library in view, you should call the library in your controller and pass the converted number to view
– TIGER
Nov 24 '18 at 6:47
Possible duplicate of codeigniter - loading a library from a view?
– TIGER
Nov 24 '18 at 6:47
Possible duplicate of codeigniter - loading a library from a view?
– TIGER
Nov 24 '18 at 6:47
okey..how do i call the function in view page..??
– dhara
Nov 24 '18 at 6:49
okey..how do i call the function in view page..??
– dhara
Nov 24 '18 at 6:49
Include a copy of your library
– Alex
Nov 24 '18 at 8:33
Include a copy of your library
– Alex
Nov 24 '18 at 8:33
didn't understand@Alex
– dhara
Nov 24 '18 at 8:56
didn't understand@Alex
– dhara
Nov 24 '18 at 8:56
add a comment |
2 Answers
2
active
oldest
votes
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>
add a comment |
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.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455801%2fhow-to-call-own-library-in-view-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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>
add a comment |
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>
add a comment |
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>
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>
answered Nov 24 '18 at 12:05
dharadhara
20314
20314
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 24 '18 at 16:12
DFriendDFriend
6,9421520
6,9421520
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53455801%2fhow-to-call-own-library-in-view-page%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
it is not a good practice to call library in view, you should call the library in your controller and pass the converted number to view
– TIGER
Nov 24 '18 at 6:47
Possible duplicate of codeigniter - loading a library from a view?
– TIGER
Nov 24 '18 at 6:47
okey..how do i call the function in view page..??
– dhara
Nov 24 '18 at 6:49
Include a copy of your library
– Alex
Nov 24 '18 at 8:33
didn't understand@Alex
– dhara
Nov 24 '18 at 8:56