マクロを使用zend_declare_class_constant_stringl
して定数プロパティを宣言していますが、定数の読み方がわかりません。宣言コード:
zend_declare_class_constant_stringl(myclass_ce,ZEND_STRL("WEL"),ZEND_STRL("welcome\n") TSRMLS_CC);
zend_read_property
定数プロパティを使用または読み取りたいzend_read_static_property
のですが、機能しません!
(1): 私はzend_read_static_property
:
ZEND_METHOD(myclass,getName){
zval *name;
char *str;
zend_class_entry *ce;
ce=Z_OBJCE_P(getThis());
name=zend_read_static_property(ce,ZEND_STRL("name"),0 TSRMLS_CC);
str=Z_STRVAL_P(name);
RETURN_STRINGL(str,Z_STRLEN_P(name),1);
}
[root@localhost myext]# php -f /var/www/html/myclass.php
Notice: Undefined property: myclass::$WEL in /var/www/html/myclass.php on line 3
(null)PHP Fatal error: Access to undeclared static property: myclass::$name in /var/www/html/myclass.php on line 5
(2) 私は zend_read_property を使用しています:
ZEND_METHOD(myclass,getName){
zval *name;
char *str;
zend_class_entry *ce;
ce=Z_OBJCE_P(getThis());
name=zend_read_property(ce,getThis(),ZEND_STRL("name"),0 TSRMLS_CC);
str=Z_STRVAL_P(name);
RETURN_STRINGL(str,Z_STRLEN_P(name),1);
}
[root@localhost myext]# php -f /var/www/html/myclass.php
Notice: Undefined property: myclass::$WEL in /var/www/html/myclass.php on line 3
(null)silenceperPHP Fatal error: Access to undeclared static property: myclass::$BYE in Unknown on line 0