내 개발 과정에서 콜백 함수가 어떻게 도움이 될 수 있습니까? 특히 PHP와. 나는 php와 프로그래밍 자체에 익숙하지 않지만 jquery와 같은 js 라이브러리에서 콜백의 힘을 보았다. 나는 PHP에서 콜백 일한하지만 난 그것에 대해 질문을 많이 물어 남아 있었다 : 콜백 함수의 범위는 실용적인 콜백 함수
- 을 명시 적으로) 여기
$post->add_callbacks('email', array($this, '_unique_email'));
// Define the callback method
/*
* Callback method that checks for uniqueness of email
*
* @param Validation $array Validation object
* @param string $field name of field being validated
*/
public function _unique_email(Validation $array, $field)
{
// check the database for existing records
$email_exists = (bool) ORM::factory('user')->where('email', $array[$field])->count_all();
if ($email_exists)
{
// add error to validation object
$array->add_error($field, 'email_exists');
}
}
이 콜백 작업을 어떻게했는지? 매개 변수의 출처는 어디입니까?