php如何写回调函数,php – 如何使用类方法作为回调函数?
生活随笔
收集整理的這篇文章主要介紹了
php如何写回调函数,php – 如何使用类方法作为回调函数?
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
如果我在類函數中使用array_walk來調用同一個類的另一個函數
class user
{
public function getUserFields($userIdsArray,$fieldsArray)
{
if((isNonEmptyArray($userIdsArray)) && (isNonEmptyArray($fieldsArray)))
{
array_walk($fieldsArray, 'test_print');
}
}
private function test_print($item, $key)
{
//replace the $item if it matches something
}
}
它給我以下錯誤 –
Warning: array_walk() [function.array-walk]: Unable to call
test_print() – function does not exist in …
那么,如何在使用array_walk()時指定$ this-> test_print()?
總結
以上是生活随笔為你收集整理的php如何写回调函数,php – 如何使用类方法作为回调函数?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iis php 0x80070032,访
- 下一篇: 华为WATCH Ultimate非凡大师