#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 4)
zend_bool jit_initialization = (PG(auto_globals_jit) && !PG(register_globals) && !PG(register_long_arrays));
#else
zend_bool jit_initialization = PG(auto_globals_jit);
#endif
先判断auto_globals_jit设置,假如PHP设置没有将_SERVER,_ENV,_REQUEST加到全局符号表中,我们在读取_SERVER,_ENV,_REQUEST时就得主动将其加到symbol_table中,然后才能找到,如:
if (jit_initialization) {
zend_is_auto_global(ZEND_STRL("_SERVER") TSRMLS_CC);
}
(void)zend_hash_find(&EG(symbol_table), ZEND_STRS("_SERVER"), (void **)&carrier);
zend_is_auto_global方法在Zend/zend_commpile.c文件中,我们可以看到在zend_is_auto_global_quick方法中调用了其回调函数:
zend_bool zend_is_auto_global_quick(const char *name, uint name_len, ulong hashval TSRMLS_DC) /* {{{ */
{
zend_auto_global *auto_global;
ulong hash = hashval ? hashval : zend_hash_func(name, name_len+1);
if (zend_hash_quick_find(CG(auto_globals), name, name_len+1, hash, (void **) &auto_global)==SUCCESS) {
if (auto_global->armed) {
auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC);
}
return 1;
}
return 0;
}
/* }}} */
zend_bool zend_is_auto_global(const char *name, uint name_len TSRMLS_DC) /* {{{ */
{
return zend_is_auto_global_quick(name, name_len, 0 TSRMLS_CC);
}
mark;