0

If I have a set of functions

private function create() { echo "create...."; }
private function read() { echo "read...."; }
private function edit() { echo "edit...."; }
..

And how to use

if(is_callable($this,"create")) {
    call_user_func(array($this, "createe"), 'Hello World');
} else {
    echo "not found";
} 

Also if I have a set of static functions

private static function create() { echo "create...."; }
private static function read() { echo "read...."; }
private static function edit() { echo "edit...."; }
..

How to use this variant?

if(functon_exists("self::create")) {
    call_user_func(array($this, "createe"), 'Hello World');
} else {
    echo "not found";
} 

Thanks

2

1 Answer 1

0

For the static function, use:

call_user_func(array('NameOfClass', 'create'));

or

call_user_func(array(get_class(), 'create'));
Sign up to request clarification or add additional context in comments.

1 Comment

Or call_user_func('NameOfClass::create');

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.