dtzk85937 2017-02-13 06:16
浏览 35

无法访问codeigniter库中的功能

New to PHP, oop & codeigniter. My CI version is 3.1.2.

I am trying to load a library that I built, trying to understand Object oriented principles. Probably I'm missing something.

Below is my library.

<?php
class DPS {
    private $mode;

    public function __construct($params){
        //print_r($params);
        $this->mode = $params['mode'];
    }   

    public function get_url(){
        if($this->$mode == "TEST"){
            return "https://uat.paymentexpress.com/pxaccess/pxpay.aspx";
        } elseif($this->$mode == "LIVE"){
            return "https://sec.paymentexpress.com/pxaccess/pxpay.aspx";
        }
    }
}
?>

I'm trying to access the get_url method in the controller below.

$params = [ 'mode' => 'TEST'];
$dps = $this->load->library('DPS',$params);     
echo $dps->get_url();

Codeigniter is throwing the below error message.

Fatal error: Call to undefined method CI_Loader::get_url()

Being a newbie I'm probably missing some sort of OO fancy thingi. I just can't figure it out. Any help is greatly appreciated.

Thank you in advance

  • 写回答

2条回答 默认 最新

  • dsf8897 2017-02-13 06:29
    关注

    Try this,

    $this->load->library('dps',$params);     
    echo $this->dps->get_url();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)