//Zend/zend_hash.h
typedef struct bucket {
ulong h; /* Used for numeric indexing */
uint nKeyLength;
void *pData;
void *pDataPtr;
struct bucket *pListNext;
struct bucket *pListLast;
struct bucket *pNext;
struct bucket *pLast;
const char *arKey;
} Bucket;
typedef struct _hashtable {
uint nTableSize;
uint nTableMask;
uint nNumOfElements;
ulong nNextFreeElement;
Bucket *pInternalPointer; /* Used for element traversal */
Bucket *pListHead;
Bucket *pListTail;
Bucket **arBuckets;
dtor_func_t pDestructor;
zend_bool persistent;
unsigned char nApplyCount;
zend_bool bApplyProtection;
#if ZEND_DEBUG
int inconsistent;
#endif
} HashTable;
// Zend/zend.h php的弱类型原理:
typedef union _zvalue_value {
long lval; /* long value */
double dval; /* double value */
struct {
char *val;
int len;
} str;
HashTable *ht; /* hash table value */
zend_object_value obj;
} zvalue_value;
struct _zval_struct {
/* Variable information */
zvalue_value value; /* value */
zend_uint refcount__gc;
zend_uchar type; /* active type */
zend_uchar is_ref__gc;
};
/* data types */
/* All data types <= IS_BOOL have their constructor/destructors skipped */
#define IS_NULL 0
#define IS_LONG 1
#define IS_DOUBLE 2
#define IS_BOOL 3
#define IS_ARRAY 4
#define IS_OBJECT 5
#define IS_STRING 6
#define IS_RESOURCE 7
#define IS_CONSTANT 8
#define IS_CONSTANT_ARRAY 9
#define IS_CALLABLE 10
//php.ini相关的源码:
//main/php_globals.h
struct _php_core_globals {
zend_bool implicit_flush;
long output_buffering;
zend_bool sql_safe_mode;
zend_bool enable_dl;
char *output_handler;
char *unserialize_callback_func;
long serialize_precision;
long memory_limit;
long max_input_time;
zend_bool track_errors;
zend_bool display_errors;
zend_bool display_startup_errors;
zend_bool log_errors;
long log_errors_max_len;
zend_bool ignore_repeated_errors;
zend_bool ignore_repeated_source;
zend_bool report_memleaks;
char *error_log;
char *doc_root;
char *user_dir;
char *include_path;
char *open_basedir;
char *extension_dir;
char *php_binary;
char *sys_temp_dir;
char *upload_tmp_dir;
long upload_max_filesize;
char *error_append_string;
char *error_prepend_string;
char *auto_prepend_file;
char *auto_append_file;
arg_separators arg_separator;
char *variables_order;
HashTable rfc1867_protected_variables;
short connection_status;
short ignore_user_abort;
unsigned char header_is_being_sent;
zend_llist tick_functions;
zval *http_globals[6];
zend_bool expose_php;
zend_bool register_argc_argv;
zend_bool auto_globals_jit;
char *docref_root;
char *docref_ext;
zend_bool html_errors;
zend_bool xmlrpc_errors;
long xmlrpc_error_number;
zend_bool activated_auto_globals[8];
zend_bool modules_activated;
zend_bool file_uploads;
zend_bool during_request_startup;
zend_bool allow_url_fopen;
zend_bool enable_post_data_reading;
zend_bool always_populate_raw_post_data;
zend_bool report_zend_debug;
int last_error_type;
char *last_error_message;
char *last_error_file;
int last_error_lineno;
char *disable_functions;
char *disable_classes;
zend_bool allow_url_include;
zend_bool exit_on_timeout;
#ifdef PHP_WIN32
zend_bool com_initialized;
#endif
long max_input_nesting_level;
long max_input_vars;
zend_bool in_user_include;
char *user_ini_filename;
long user_ini_cache_ttl;
char *request_order;
zend_bool mail_x_header;
char *mail_log;
zend_bool in_error_log;
#ifdef PHP_WIN32
zend_bool windows_show_crt_warning;
#endif
};