Welcome Guest, Not a member yet? Register   Sign In
how to access class data member from a hook file?
#1

[eluser]prestondocks[/eluser]
Hi, I have defined a hook file for which I want to access and a data member in the class being called.

The code in my hook file looks like this
Code:
class Security
{

function module_permission()
{
$CI =& get_instance();
$class = $CI->router->class;
$method = $CI->router->method;
echo $CI->$class->sec_test;
}
}

But I am getting the following error

Code:
A PHP Error was encountered
Severity: Notice

Message: Undefined property: CI::$meetings

Filename: hooks/security.php

Line Number: 11

A PHP Error was encountered
Severity: Notice

Message: Trying to get property of non-object

Filename: hooks/security.php

Line Number: 11

I am using the post_controller_constructer hook

I am also using HMVC

Can anyone help me to solve this issue?

Thanks for any help,
#2

[eluser]Dennis Rasmussen[/eluser]
Where is the variable $meetings defined?
#3

[eluser]prestondocks[/eluser]
$meetings is not a variable. I am using $class as the variable, which has the value of "meetings" taken from $CI->router->class.

Your question did make me realise that class is a reserved name, but even after changing this variable to $called_class rather than $class, I get the same error.
#4

[eluser]Dennis Rasmussen[/eluser]
Okay but the reason I'm asking is because the error says that the property CI->$meetings isn't defined.
So you need to make sure it's defined or not call it at all.
#5

[eluser]InsiteFX[/eluser]
Also I would change the name of your class because CodeIgniter 2.0
has a Security class!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB