1

I have a function in a class with this code:

$this -> userDb;
$error = $this -> error;
print_r($error);

userDb is another function in this class and error is generated by userDb. It always gives a non-empty array.

Why wouldn't I be able to get the value of $this -> error?

1
  • Try posting the whole class, please? Commented Apr 19, 2011 at 11:01

3 Answers 3

1

First userDb is function but you aren't calling the function. You have to call userDb as

$this->userDb();

Sign up to request clarification or add additional context in comments.

1 Comment

I think I was getting VB syntex mixed in there
0

to call a method (function) you must use parentheses:

$this->userDb();

Comments

0

Without seeing the code for the userDb function, it's difficult to explain why the error is caused. However, if you're trying to call the function, you need to include the brackets in the function call:

$this->userDb();
print_r($this->error);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.