Welcome Guest, Not a member yet? Register   Sign In
Undefined variable
#1

[eluser]Unknown[/eluser]
Hi Codeigniter Community

I've been coding in Codeigniter for the last couple of weeks - and it really is amazing.

One thing is causing me some problems.

Consider this controller:

Code:
class main_page extends Controller {

    function main_page()
    {
        parent::Controller();
    }

    function index()
    {
                if($variable_name) {
                //Do something intelligent
                }
    }
}

This would trigger the "undefined variable" error. I know $variable_name isn't defined, but as far as I know, this isn't necessary in PHP.
Because of this I have been using the syntax

Code:
if(@$variable_name) {
//Do something intelligent
}

Is there a better way?


Messages In This Thread
Undefined variable - by El Forum - 02-11-2009, 05:02 AM
Undefined variable - by El Forum - 02-11-2009, 05:09 AM
Undefined variable - by El Forum - 02-11-2009, 05:16 AM
Undefined variable - by El Forum - 02-11-2009, 05:17 AM
Undefined variable - by El Forum - 02-11-2009, 05:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB