5

A simple PHP problem I couldn't find the answer to.

Is it possible to call a function from the "__construct()"?

For example if I use the My_Controller solution here. If I add my own function below, like if I have a more advanced auth, can I call it from the construct?

3
  • 7
    Have you tried it? Of course you can call functions inside methods. Commented Jun 30, 2011 at 11:03
  • oh my god..... that was the most embarrassing brainfreeze moment in a very long time. Tried it and ofc it worked like a charm.. :) Thanks Commented Jun 30, 2011 at 11:24
  • No worries, such things happen :) But it is always better to try things first ;) Commented Jun 30, 2011 at 11:26

1 Answer 1

8

Yes, using the format $this->myNewFunction();

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

1 Comment

how on earth did this get to be -1??! +1 because it's right!

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.