类(Classes)

    在 ext 目录增加 auth.h 文件,注册 Phalcon\Auth 类:

    然后,我们创建 auth.c 文件,在里面添加方法的原型:

    1. PHP_METHOD(Phalcon_Auth, getIdentity);
    2. PHP_METHOD(Phalcon_Auth, auth);

    现在,我们将所有方法赋予指定的类:

    1. static const zend_function_entry phalcon_auth_method_entry[] = {
    2. PHP_ME(Phalcon_Auth, getIdentity, NULL, ZEND_ACC_PUBLIC)
    3. PHP_ME(Phalcon_Auth, auth, NULL, ZEND_ACC_PUBLIC)
    4. PHP_FE_END

    仍然在 auth.c 文件中,我们添加代码:

    1. PHP_METHOD(Phalcon_Auth, __construct){

    If the method has parameters we receive them using zend_parse_parameters:

    If we do not receive the correct number of parameters will result in an error message. You see, there’s an argument“zz” to receive the parameters, this indicates the type of data received and the number of them. In the above examplethat means that the method is receiving two parameters. If they were three zval then it should be “zzz”.