<? PHP class test{ static $name ="ABC";} echo Test:: $name;
1. The Pasteur Paradigm
class_statement:variable_modifiers {CG (access_type)= Z_lval ($1. u.constant); } class_variable_declaration';'; member_modifier:t_public {z_lval ($$.u.constant)=Zend_acc_public;} | t_protected {z_lval ($$.u.constant) =zend_acc_protected;} | t_private {z_lval ($$.u.constant) =Zend_acc_private;} | t_static {z_lval ($$.u.constant) =zend_acc_static;} | t_abstract {z_lval ($$.u.constant) =Zend_acc_abstract;} | t_final {z_lval ($$.u.constant) =zend_acc_final;}; Class_variable_declaration:class_variable_declaration','t_variable {Zend_do_declare_property (&$3, NULL, CG (Access_type) tsrmls_cc); } | Class_variable_declaration','T_variable'='static_scalar {Zend_do_declare_property (&$3, &$5, CG (Access_type) tsrmls_cc); } | t_variable {Zend_do_declare_property (&$1, NULL, CG (Access_type) tsrmls_cc); } | T_variable'='static_scalar {Zend_do_declare_property (&$1, &$3, CG (Access_type) tsrmls_cc); };variable:base_variable_with_function_calls {$$= $1; }; base_variable_with_function_calls:base_variable {$$= $1; } ; base_variable:static_member {$$= $1; $$. EA =Zend_parsed_static_member;}; Static_member:class_name T_paamayim_nekudotayim variable_without_objects {$$= $3; Zend_do_fetch_static_member (&$$, &$1tsrmls_cc); };
Understanding version
class_statement:variable_modifiers {CG (access_type)= Z_lval ($1. u.constant); } class_variable_declaration';'; member_modifier:t_public {z_lval ($$.u.constant)=Zend_acc_public;} | t_protected {z_lval ($$.u.constant) =zend_acc_protected;} | t_private {z_lval ($$.u.constant) =Zend_acc_private;} | t_static {z_lval ($$.u.constant) =zend_acc_static;} | t_abstract {z_lval ($$.u.constant) =Zend_acc_abstract;} | t_final {z_lval ($$.u.constant) =zend_acc_final;}; Class_variable_declaration:class_variable_declaration','t_variable {Zend_do_declare_property (&$3, NULL, CG (Access_type) tsrmls_cc); } | Class_variable_declaration','T_variable'='static_scalar {Zend_do_declare_property (&$3, &$5, CG (Access_type) tsrmls_cc); } | t_variable {Zend_do_declare_property (&$1, NULL, CG (Access_type) tsrmls_cc); } | T_variable'='static_scalar {Zend_do_declare_property (&$1, &$3, CG (Access_type) tsrmls_cc); };variable:t_string T_paamayim_nekudotayim t_variable {$$= $3; Zend_do_fetch_static_member (&$$, &$1tsrmls_cc); };
2. For static $name = "ABC"
The organization PROPERT_INFO the structure, which is stored in the Hashtable as the property_info of the class,
Note: value is in the existence of the property_table in the class, where key is offset in Property_info
voidZend_do_declare_property (ConstZnode *var_name,ConstZnode *value, Zend_uint access_type tsrmls_dc)/* {{{ */{zval*Property ; Alloc_zval (property); if(value) {*property = value->u.constant; } Else{Init_pzval (property); Z_type_p (property)=Is_null; } zend_declare_property_ex (CG (Active_class_entry), zend_new_interned_string (Z_strval (Var_name->u.constant), Z_strlen (var_name->u.constant) +1,0TSRMLS_CC), Z_strlen (var_name->u.constant), property, Access_type, comment, Comment_len tsrmls_cc);}
Zend_apiintZEND_DECLARE_PROPERTY_EX (Zend_class_entry *ce,Const Char*name,intName_length, Zval *property,intAccess_type,Const Char*doc_comment,intDoc_comment_len tsrmls_dc)/* {{{ */{zend_property_info Property_info,*property_info_ptr; Const Char*Interned_name; ULONGh = zend_get_hash_value (name, name_length+1); if(Access_type &zend_acc_static) { //If it is a static member variable, the required memory is allocated using Relloc, and size (zval*) *ce->default_static_member_count is the total memory property_info.o Ffset= ce->default_static_members_count++; Ce->default_static_members_table = Perealloc (ce->default_static_members_table,sizeof(zval*) * Ce->default_static_members_count, Ce->type = =Zend_internal_class); Ce->default_static_members_table[property_info.offset] =Property ; if(Ce->type = =Zend_user_class) {CE->static_members_table = ce->default_static_members_table; } } Else{Property_info.offset= ce->default_properties_count++; Ce->default_properties_table = Perealloc (ce->default_properties_table,sizeof(zval*) * Ce->default_properties_count, Ce->type = =Zend_internal_class); Ce->default_properties_table[property_info.offset] =Property ; } interned_name= Zend_new_interned_string (Property_info.name, property_info.name_length+1,0tsrmls_cc); if(Interned_name! =property_info.name) { if(Ce->type = =Zend_user_class) {Efree (Char*) property_info.name); } Else{free (Char*) property_info.name); } property_info.name=Interned_name; } property_info.flags=Access_type; Property_info.h= (Access_type & zend_acc_public)? H:zend_get_hash_value (Property_info.name, property_info.name_length+1); Property_info.ce=CE; Zend_hash_quick_update (&ce->properties_info, name, name_length+1, H, &property_info,sizeof(Zend_property_info), NULL); returnSUCCESS;}
PHP class static variable assignment static $name = "ABC"