title: I can't call a static function from another controller in codeigniter. Why?
body: <p>I have started to create a controller called <strong>User</strong> in codeigniter</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  class User extends CI_Controller {
  
          public function __construct() {
              parent::__construct();
              $this-&gt;load-&gt;helper(array('form', 'url'));
              $this-&gt;load-&gt;library(array( 'encrypt', 'form_validation' ));
          }
  
          public function index()
          {                
          }
  
          /*
           * Create loginform
           * Parameters:  void
           * Return:      html of loginform;
           */
          public static function loginform() {
  
                  // Login form setup
                  $loginform_data = array();                  
                  $loginform_data['attributes']       = array('id'  =&gt; 'loginform');  
                  $loginform_data['username']         = array(
                                                              'name'        =&gt; 'username',
                                                              'id'          =&gt; 'username',
                                                              'value'       =&gt; '',
                                                              'maxlength'   =&gt; '100'                                                    
                                                      );                
                  $loginform_data['pass']             = array(
                                                              'name'        =&gt; 'pass',
                                                              'id'          =&gt; 'pass',
                                                              'value'       =&gt; '',
                                                              'maxlength'   =&gt; '100'                                                    
                                                      );      
  
                  $contentdata = array();
                  $contentdata['loginform'] = $this-&gt;load-&gt;view('partials/forms/login', $loginform_data, true);
                  return $contentdata;
          }
  
          /*
           * Check login username, password from form
           * Parameters:  void
           * Return:      void;
           */
          public function login() {
                  $name = $this-&gt;input-&gt;post('username');
                  $pass = $this-&gt;input-&gt;post('pass');
  
                  $this-&gt;form_validation-&gt;set_rules('username', 'Användarnamn', 'required');
                  $this-&gt;form_validation-&gt;set_rules('pass', 'Lösenord', 'required');
  
                  if ($this-&gt;form_validation-&gt;run() == false)
                  {
                          $this-&gt;load-&gt;view('home');
                  } 
                  else
                  {
                          $this-&gt;load-&gt;view('formsuccess');
                  }
              }
  }
  </code></pre>
  
  <p>I can call the user/login - function through the url. But I can't call <code>User::loginform()</code> from another controller. <strong>Shouldn't I be able to do that?</strong></p>
  
  <p>Here's what I'm trying: (from my Home-class)</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
  class Home extends CI_Controller {
  
      public function index()
      {
                  //Create login and register-forms
                  $this-&gt;load-&gt;helper('form');
  
                  //Registration form setup               
                  $registerform_data = array();                  
                  $registerform_data['attributes']    = array('id'  =&gt; 'registerform');  
                  $registerform_data['company']       = array(
                                                              'name'        =&gt; 'name-company',
                                                              'id'          =&gt; 'name-company',
                                                              'value'       =&gt; '',
                                                              'maxlength'   =&gt; '100'                                                    
                                                      );                
                  $registerform_data['orgnr']         = array(
                                                              'name'        =&gt; 'orgnr-company',
                                                              'id'          =&gt; 'orgnr-company',
                                                              'value'       =&gt; '',
                                                              'maxlength'   =&gt; '100'                                                    
                                                      );        
                  $registerform_data['contact']       = array(
                                                              'name'        =&gt; 'contact-company',
                                                              'id'          =&gt; 'contact-company',
                                                              'value'       =&gt; '',
                                                              'maxlength'   =&gt; '100'                                                    
                                                      );                      
                  $registerform_data['phonecompany']  = array(
                                                              'name'        =&gt; 'phone-company',
                                                              'id'          =&gt; 'phone-company',
                                                              'value'       =&gt; '',
                                                              'maxlength'   =&gt; '100'                                                    
                                                      );                          
                  $registerform_data['emailcompany']  = array(
                                                              'name'        =&gt; 'email-company',
                                                              'id'          =&gt; 'email-company',
                                                              'value'       =&gt; '',
                                                              'maxlength'   =&gt; '100'                                                    
                                                      );   
  
  
  
  
                  //What content to pass to view       
                  $contentdata = array();
                  $contentdata['loginform'] = User::loginform();
                  $contentdata['registerform'] = $this-&gt;load-&gt;view('partials/forms/registration', $registerform_data, true);                
  
                  $this-&gt;load-&gt;view('home', $contentdata);
      }
  }
  </code></pre>
  
  <p><code>$contentdata['loginform'] = User::loginform();</code> gives me error:<code>Fatal error: Class 'User' not found in C:\Program...</code></p>
  
  <p><strong>What am I missing?</strong></p>