php pass function as callback

Solutions on MaxInterview for php pass function as callback by the best coders in the world

showing results for - "php pass function as callback"
Lisa
21 Jan 2020
1
2<?php
3
4// An example callback function
5function my_callback_function({
6    echo 'hello world!';
7}
8
9// An example callback method
10class MyClass {
11    static function myCallbackMethod({
12        echo 'Hello World!';
13    }
14}
15
16// Type 1: Simple callback
17call_user_func('my_callback_function');
18
19// Type 2: Static class method call
20call_user_func(array('MyClass''myCallbackMethod'));
21
22