php如何写回调函数,php – 如何使用类方法作为回调函数?
生活随笔
收集整理的這篇文章主要介紹了
php如何写回调函数,php – 如何使用类方法作为回调函数?
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
如果我在類函數(shù)中使用array_walk來(lái)調(diào)用同一個(gè)類的另一個(gè)函數(shù)
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
}
}
它給我以下錯(cuò)誤 –
Warning: array_walk() [function.array-walk]: Unable to call
test_print() – function does not exist in …
那么,如何在使用array_walk()時(shí)指定$ this-> test_print()?
總結(jié)
以上是生活随笔為你收集整理的php如何写回调函数,php – 如何使用类方法作为回调函数?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: iis php 0x80070032,访
- 下一篇: 磁盘io php,PHP CURL如何处