v5_6000 发表于 2010-8-13 14:50:41

自定义类应该如何加载

本帖最后由 v5_6000 于 2010-8-13 14:52 编辑

需要定义一个对象的包装类(Res_text.php)。包含对象的各种属性和方法。
这个类不需要继承父类。现在是把文件保存在models目录下了。

在moudel(Blogmodel.php)中$res_text = new Res_text;的时候报错找不到这个类。PHP Fatal error:Class 'Res_text' not found in F:\\codeCenter\\ci\\system\\application\\models\\Blogmodel.php on line 32应该把这个类放在上磁盘什么位置上,或者如何配置才能找到这个类?

包装类Res_text.php

<?php
class Res_text
{
    var $id;
   
    function Res_text()
    {
      
    }
   
    function get_id()
    {
      return "222";
    }

    function show_me()
    {
      echo "show me!";
    }
}
?>

lamtin 发表于 2010-8-13 15:10:18

http://codeigniter.org.cn/user_guide/general/creating_libraries.html
页: [1]
查看完整版本: 自定义类应该如何加载