自己的类库Codeigniter [英] Own class library Codeigniter
本文介绍了自己的类库Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好!我尝试创建自己的库类并从其他类调用它。
我创建了文件SimpleImage.php并将其放在目录application / libraries /
文件内容类:< br $> b $ b
Hello! I try make own library class and call it from other class.
I created file SimpleImage.php and put it at directory application/libraries/
The file contents class:
<?
class SimpleImage {
var $image;
var $image_type;
function load($filename) {
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if( $this->image_type == IMAGETYPE_JPEG ) {
$this->image = imagecreatefromjpeg($filename);
} elseif( $this->image_type == IMAGETYPE_GIF ) {
$this->image = imagecreatefromgif($filename);
} elseif( $this->image_type == IMAGETYPE_PNG ) {
$this->image = imagecreatefrompng($filename);
}
}
}
?>
我还有其他类库Myupload.php和类:
I have also other library class Myupload.php with class:
<?
class Myupload {
function UploadFiles($options)
{
$CI = & get_instance();
$CI->load->library('SimpleImage');
$CI->SimpleImage->load($path.$info_file['file_name']); // 44 line
$CI->SimpleImage->resize(200,200);
$CI->SimpleImage->save($path.$info_file['raw_name'].'_thumb.'.$info_file['file_ext']);
}
}
?>
但它给了我错误:
But it gives me error:
Severity: Notice
Message: Undefined property: Apartaments::$SimpleImage
Filename: libraries/Myupload.php
Line Number: 44
什么是错的?
What is wrong?
推荐答案
image ;
var
image; var
image_type ;
函数加载(
image_type; function load(
filename){
filename) {
>
这篇关于自己的类库Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文