form_validation类未加载(codeigniter) [英] form_validation class does not load (codeigniter)

查看:60
本文介绍了form_validation类未加载(codeigniter)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本无法加载form_validation类.

My script fails to load form_validation class.

我从autoload.php,控制器的_ construct 方法以及我打算使用的方法(即login()方法)

I called it from autoload.php, controller's _construct method and the method i was intend to use (ie. login() method)

autoload.php

$autoload['libraries'] = array('database', 'Login', 'Template', 'form_validation', 'session');

控制器

<?php
class Login extends CI_Controller
{
function __construct()
{
    parent::__construct();
    $this->load->model('user_model');
    $this->load->library('form_validation');
}

function logmein()
{       
    $this->load->library('form_validation');
    $this->form_validation->set_rules('userEmail', 'email', 'trim|required|valid_email|callback__check_login');
    $this->form_validation->set_rules('userPassword', 'password', 'trim|required');

请注意,我没有尝试从所有三个地方加载该类,我只尝试了每个地方,也没有尝试任何组合,但是都没有成功.我正在 windows 7 上的 XAMPP 在我的本地主机上运行 PHP版本5.3.5 .我真正的服务器是linux,所以如果它在linux上运行良好,我可以忍受==

please do note that, i did not try to load the class from all the three places, i tried each one solely, and the combinations, but no success. I'm running PHP Version 5.3.5 on my localhost with XAMPP on windows 7. My real server is linux so if it works well on linux, i can live with that =)

更新:我已经将var_dumped并检查了资源,并且_user_model_和_form_validation_似乎都工作良好.但是,当我var_dump($this->user_model)var_dump($this->form_validation)返回NULL时.

update: i have var_dumped and checked the resources, and both _user_model_ and _form_validation_ seem to work well. however, when i var_dump($this->user_model) or var_dump($this->form_validation) returns NULL.

推荐答案

我的所有代码实际上都没有错误.

All of my code was actually error-less.

但是,在我的一个库类中,我扩展了一个控制器类来加载另一个导致所有错误的库.

However in one of my library classes, i have extended a controller class to load another library which was causing all of my errors.

我已将其删除,并使用$CI =& get_instance();方法加载其他类,并且现在一切正常.

I have removed it and used $CI =& get_instance(); method for loading other classes and everything works fine now.

这篇关于form_validation类未加载(codeigniter)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆