Welcome Guest, Not a member yet? Register   Sign In
libraries not loading from controller methods
#1

[eluser]Jack Scott[/eluser]
I'm having trouble loading libraries from controller methods in PHP 5.2.6 under Mac OS 10.5.6. Library loading seems to work ok in PHP 4.3.9.

I was able to recreate this problem with an unmodified copy of CI 1.7.1.

Inside system/application/controllers/welcome.php, at the top of the index() method, I added the code:

$this->load->library('form_validation');
print_r($this->form_validation);

Under PHP 5.2.6, I see the error message "Undefined property: Welcome::$form_validation". Trying to access any variable or method under $this->form_validation results in a fatal error. The code works as expected if I move $this->load->library() to the constructor. It also works as expected if I move both lines to the constructor.

The code also works as expected under PHP 4.3.9 under Linux.

Has anyone encountered this before? Is it a CI bug, a PHP5 weirdness, or something strange in Mac OS X's PHP?

Jack
#2

[eluser]Jack Scott[/eluser]
Upgrading to PHP 5.2.9 seems to fix this problem.

I used the PHP 5.2.9 install package from http://www.entropy.ch/software/macosx/php/

Jack
#3

[eluser]Nexus Rex[/eluser]
I am experiencing this exact error under PHP 5.2.9 on a server with BlueHost. The only way to get form_validation to work is to add it to the autoload.php - not the ideal situation!




Theme © iAndrew 2016 - Forum software by © MyBB