1

Hello i would like to ask: How to call static function from constructor in same class PHP?

I have got:

public function __construct()

And I need to call this function

private function _regenerateThumbnails($type = 'all', $deleteOldImages = false)

in constructor.

Is it possible in PHP and if yes, how?

Thanks for any advice.

1 Answer 1

11

First of all, you should explicitly declare that method static, like this:

private static function _regenerateThumbnails($type = 'all', $deleteOldImages = false)

To call it in your constructor, use the self keyword:

public function __construct() {
    // Pass arguments from your constructor to your method
    // where appropriate
    self::_regenerateThumbnails();
}
Sign up to request clarification or add additional context in comments.

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.