同一类中的CodeIgniter调用函数 [英] CodeIgniter call function within the same class
本文介绍了同一类中的CodeIgniter调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在我的CodeIgniter应用程序中执行以下代码:
I am trying to do this code in my CodeIgniter application :
<?php
class Inventory extends Controller {
function current_stock()
{
//do something
}
function add_stock()
{
//do something-else
****then do function current_stock()*****
}
}
如何在第二个函数中执行另一个函数?
这里
How do I execute another function from within a second one? The approach outlined here (about extending controllers) is something of an overkill for me.
我错过了一种简单得多的方法吗?
Am I missing a much easier way?
推荐答案
好的,我同意这是一个大问题。来自缺乏对OOP的理解;
OK, I agree this is a MAJOR goof-up; comes from lack of OOP understanding;
<?php
class Inventory extends Controller {
function current_stock() {
//do something
}
function add_stock() {
//do something-else
$this->current_stock();
// and we called the other method here!
}
}
我只是没想到会如此简单
Just that I didn"t expect it to be so easy
这篇关于同一类中的CodeIgniter调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文