php學習之函式呼叫 call

2021-10-21 02:44:45 字數 1155 閱讀 8253

摘要:

內容:

1、forward_static_call  vs forward_static_call_array

forward_static_call  傳入的引數是正常的單個引數由逗號隔開, forward_static_call_array 傳入的引數則由陣列包裹,第乙個引數均為函式名

傳入的引數需要用 func_get_args 獲取

class a

}// a 為class 名稱 test 為 class 函式

forward_static_call(array('a', 'test'), 'more', 'args');

forward_static_call( 'test', 'other', 'args');

forward_static_call_array(array('a', 'test'), array('more', 'args'));

forward_static_call_array( 'test', array('other', 'args'));

2、call_user_func vs call_user_func_array

傳入引數的區別和第一條一樣

call_user_func(array('a', 'test'), 'more', 'args');

call_user_func_array(array('a', 'test'), array('more', 'args'));

3、 forward_static_call  vs call_user_func

forward_static_call 會繼承靜態函式的上下文

call_user_func 並不會繼承上下文

class b extends a 

}b::test('foo');

//b//b more,args

class b extends a

}b::test('foo');

//b//a more,args

總結:

CSP2020 函式呼叫(call)

大概就是對於所有的1 2號操作先不做考慮,先考慮3號 對於所有的3操作將該點與所有的需進行的操作連一條有向邊 然後以操作從後往前拓撲 因為運算元眾多,我們考慮將所有的貢獻統一處理 設乙個mul表示該操作對全域性積的影響 則1號操作的mul為1,2號操作的mul為該點操作的值,而3號操作應該是所有的子...

PHP之 call 方法和

在php的物件導向裡,用得最多的魔術方法一定是 construct方法。而在很多很多地方,call方法和 callstatic方法用得地方一樣很多,而且特別好用呢。下面舉個應用的例子。class pay magic static call.param string method param arra...

函式呼叫 通過apply和call方法呼叫

不同型別函式呼叫之間的主要區別在於 最終作為函式上下文 可以通過this引數隱式引用到 傳遞給執行函式物件不同。對於方法而言,即為所在的物件 對於函式而言是window或是undefined 取決於是否處於嚴格模式下 對於建構函式而言是乙個新建立的物件例項。click me 在這個例子中,我們定義了...