Home Backend Development PHP Tutorial 【PHP内核学习】变量跟数据类型

【PHP内核学习】变量跟数据类型

Jun 13, 2016 am 11:56 AM
hashtable nbsp php zend

【PHP内核学习】变量和数据类型

<div class="line" id="LC1" style="padding-left:10px; height:18px">|=-----------------------------------------------------------------------=|<div class="line" id="LC2" style="padding-left:10px; height:18px">|=---------------------=[ PHP内核中的变量和数据类型]=--------------------=|<div class="line" id="LC3" style="padding-left:10px; height:18px">|=-----------------------------------------------------------------------=|<div class="line" id="LC4" style="padding-left:10px; height:18px">|=--------------------------=[ by d4shman ]=-----------------------------=|<div class="line" id="LC5" style="padding-left:10px; height:18px">|=-----------------------------------------------------------------------=|<div class="line" id="LC6" style="padding-left:10px; height:18px">|=-------------------------=[  May 6, 2014  ]=---------------------------=|<div class="line" id="LC7" style="padding-left:10px; height:18px">|=-----------------------------------------------------------------------=|<div class="line" id="LC8" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC9" style="padding-left:10px; height:18px">(_____ \| |   | (_____ \   /\   / _____) |  / )   <div class="line" id="LC10" style="padding-left:10px; height:18px"> _____) ) |__ | |_____) ) /  \ | /     | | / /    <div class="line" id="LC11" style="padding-left:10px; height:18px">|  ____/|  __)| (_____ ( / /\ \| |     | |<div class="line" id="LC12" style="padding-left:10px; height:18px">| |     | |   | |     | | |__| | \_____| | \ \    <div class="line" id="LC13" style="padding-left:10px; height:18px">|_|     |_|   |_|     |_|______|\______)_|  \_)   (向phrack致敬!)<div class="line" id="LC14" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC15" style="padding-left:10px; height:18px"><div class="line" id="LC16" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC17" style="padding-left:10px; height:18px"> 0x01  变量的结构和类型<div class="line" id="LC18" style="padding-left:10px; height:18px"> 0x02  哈希表--PHP的灵魂<div class="line" id="LC19" style="padding-left:10px; height:18px"> 0x03  常量<div class="line" id="LC20" style="padding-left:10px; height:18px"> 0x04  参考文献<div class="line" id="LC21" style="padding-left:10px; height:18px"><div class="line" id="LC22" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC23" style="padding-left:10px; height:18px">/////<div class="line" id="LC24" style="padding-left:10px; height:18px">0x01  变量的结构和类型<div class="line" id="LC25" style="padding-left:10px; height:18px">/////<div class="line" id="LC26" style="padding-left:10px; height:18px">1.数据类型<div class="line" id="LC27" style="padding-left:10px; height:18px">  1.1静态类型语言(C/Java),编译时确定<div class="line" id="LC28" style="padding-left:10px; height:18px">  1.2动态类型语言(php/python),运行时确定<div class="line" id="LC29" style="padding-left:10px; height:18px">  1.3无类型语言(汇编),操作的底层存储<div class="line" id="LC30" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC31" style="padding-left:10px; height:18px">2.php内核中所有的变量使用同一种数据结构zval来保存,而这个结构同时表示php中各种数据类型,它不仅仅包含变量的值,也包含变量的类型。这就是php弱类型的核心。<div class="line" id="LC32" style="padding-left:10px; height:18px">        php中的8中数据类型:<div class="line" id="LC33" style="padding-left:10px; height:18px">  2.1标量类型: boolean, integer, float, string<div class="line" id="LC34" style="padding-left:10px; height:18px">  2.2复合类型:  array, object<div class="line" id="LC35" style="padding-left:10px; height:18px">  2.3特殊类型: resource, null<div class="line" id="LC36" style="padding-left:10px; height:18px">  <div class="line" id="LC37" style="padding-left:10px; height:18px">3.zval结构体(在php源码目录下Zend/zend.h中定义):<div class="line" id="LC38" style="padding-left:10px; height:18px">  struct _zval_struct{<div class="line" id="LC39" style="padding-left:10px; height:18px">  	  /*Variable information*/<div class="line" id="LC40" style="padding-left:10px; height:18px">  	  zvalue_value value  	/*value, 变量的值*/<div class="line" id="LC41" style="padding-left:10px; height:18px">  	  zend_uint refcount__gc  /*reference count, 引用计数器*/<div class="line" id="LC42" style="padding-left:10px; height:18px">  	  zend_uchar type 		/*active type, 变量的类型*/<div class="line" id="LC43" style="padding-left:10px; height:18px">  	  zend_uchar is_ref__gc;  /*变量是否被引用*/<div class="line" id="LC44" style="padding-left:10px; height:18px">  }<div class="line" id="LC45" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC46" style="padding-left:10px; height:18px">4.变量类型:<div class="line" id="LC47" style="padding-left:10px; height:18px">  /*data types */<div class="line" id="LC48" style="padding-left:10px; height:18px">  #define IS_NULL		0 <div class="line" id="LC49" style="padding-left:10px; height:18px">  #define IS_LONG 		1<div class="line" id="LC50" style="padding-left:10px; height:18px">  #define IS_DOUBLE 	2<div class="line" id="LC51" style="padding-left:10px; height:18px">  #define IS_BOOL 		3<div class="line" id="LC52" style="padding-left:10px; height:18px">  #define IS_ARRAY		4<div class="line" id="LC53" style="padding-left:10px; height:18px">  #define IS_OBJECT		5<div class="line" id="LC54" style="padding-left:10px; height:18px">  #define IS_STRING 	6<div class="line" id="LC55" style="padding-left:10px; height:18px">  #define IS_RESOURCE	7<div class="line" id="LC56" style="padding-left:10px; height:18px">  #define IS_CONSTANT	8<div class="line" id="LC57" style="padding-left:10px; height:18px">  #define IS_CONSTANT_ARRAY	9<div class="line" id="LC58" style="padding-left:10px; height:18px">  #define IS_CALLABLE	10<div class="line" id="LC59" style="padding-left:10px; height:18px">  <div class="line" id="LC60" style="padding-left:10px; height:18px">5.变量的值存储<div class="line" id="LC61" style="padding-left:10px; height:18px">  typedef union _zvalue_value {<div class="line" id="LC62" style="padding-left:10px; height:18px">      long lval; 		/*long、bool、resource类型*/<div class="line" id="LC63" style="padding-left:10px; height:18px">	  double dval ;	/*double 类型*/<div class="line" id="LC64" style="padding-left:10px; height:18px">	  struct {		/*string 类型, len保存了字符串的长度*/<div class="line" id="LC65" style="padding-left:10px; height:18px">	  	char *val;<div class="line" id="LC66" style="padding-left:10px; height:18px">	  	int len;<div class="line" id="LC67" style="padding-left:10px; height:18px">	  } str;<div class="line" id="LC68" style="padding-left:10px; height:18px">	  HashTable *ht;  /*数组, 用HashTable实现*/<div class="line" id="LC69" style="padding-left:10px; height:18px">	  zend_object_value obj; /*object 类型*/<div class="line" id="LC70" style="padding-left:10px; height:18px">  } zvalue_value;<div class="line" id="LC71" style="padding-left:10px; height:18px">  <div class="line" id="LC72" style="padding-left:10px; height:18px">  这里之所以用共同体(union)是因为一个变量只可能有一种类型,符合共同体的特性,如果使用结构体则会浪费内存。<div class="line" id="LC73" style="padding-left:10px; height:18px">  <div class="line" id="LC74" style="padding-left:10px; height:18px">  实例:创建一个值为10的整型变量lvar,用php脚本的话很简单,就是:$lvar = 10<div class="line" id="LC75" style="padding-left:10px; height:18px">  而PHP内核中的实现可能就是类似下面这样:<div class="line" id="LC76" style="padding-left:10px; height:18px">  zval lval;<div class="line" id="LC77" style="padding-left:10px; height:18px">  Z_TYPE(lvar) = IS_LONG;<div class="line" id="LC78" style="padding-left:10px; height:18px">  Z_LVAL(lvar) = 10;<div class="line" id="LC79" style="padding-left:10px; height:18px">  <div class="line" id="LC80" style="padding-left:10px; height:18px">/////<div class="line" id="LC81" style="padding-left:10px; height:18px">0x02  哈希表--PHP的灵魂<div class="line" id="LC82" style="padding-left:10px; height:18px">/////<div class="line" id="LC83" style="padding-left:10px; height:18px">1.为什么用哈希表<div class="line" id="LC84" style="padding-left:10px; height:18px">  哈希表通常提供CRUD(Create, Read, Update, Delete)操作,设计合理的哈希表中,这些操作时间复杂度为O(1),这也是它被钟爱的原因。<div class="line" id="LC85" style="padding-left:10px; height:18px">  hash(key) -> index<div class="line" id="LC86" style="padding-left:10px; height:18px">  <div class="line" id="LC87" style="padding-left:10px; height:18px">2.哈希表的实现:结构体 bucket和_hashtable组成了完整的HashTable。<div class="line" id="LC88" style="padding-left:10px; height:18px">  首先看bucket结构体(定义在 Zend/zend_hash.h):<div class="line" id="LC89" style="padding-left:10px; height:18px">  typedef struct bucket {<div class="line" id="LC90" style="padding-left:10px; height:18px">	  ulong h;  					/*hash值*/<div class="line" id="LC91" style="padding-left:10px; height:18px">	  uint nKeyLength;			/*key的长度*/<div class="line" id="LC92" style="padding-left:10px; height:18px">	  void *pData;				/*要保存的内存块地址,通常是malloc来的地址*/<div class="line" id="LC93" style="padding-left:10px; height:18px">	  void *pDataPtr;				/*保存指针数据,不经过malloc的指针,防止产生内存碎片*/<div class="line" id="LC94" style="padding-left:10px; height:18px">	  struct bucket *pListNext;   /*bucket中具有同一hash值的下一个元素*/<div class="line" id="LC95" style="padding-left:10px; height:18px">	  struct bucket *pListLast;   /*bucket中具有同一hash值的上一个元素*/<div class="line" id="LC96" style="padding-left:10px; height:18px">	  struct bucket *pNext;		/*双向链表的下一个元素*/<div class="line" id="LC97" style="padding-left:10px; height:18px">	  struct bucket *pLast;       /*双向链表的上一个元素*/<div class="line" id="LC98" style="padding-left:10px; height:18px">	  const char *arKey;			/*保存key*/<div class="line" id="LC99" style="padding-left:10px; height:18px">  } Bucket;<div class="line" id="LC100" style="padding-left:10px; height:18px">  <div class="line" id="LC101" style="padding-left:10px; height:18px">  可以看出bucket是一个双向链表,这是为了解决多个key冲突的问题(即算法导论中的链接法)<div class="line" id="LC102" style="padding-left:10px; height:18px">  <div class="line" id="LC103" style="padding-left:10px; height:18px">  <div class="line" id="LC104" style="padding-left:10px; height:18px">  再看_hashtable结构体:<div class="line" id="LC105" style="padding-left:10px; height:18px">  typedef struct _hashtable {<div class="line" id="LC106" style="padding-left:10px; height:18px">      uint nTableSize;                /*bucket数组的大小*/<div class="line" id="LC107" style="padding-left:10px; height:18px">	  uint nTableMask;				<div class="line" id="LC108" style="padding-left:10px; height:18px">	  uint nNumOfElements;			/*HashTable中元素的个数*/<div class="line" id="LC109" style="padding-left:10px; height:18px">	  ulong nNextFreeElement;			/*下一个可用的Bucket位置*/<div class="line" id="LC110" style="padding-left:10px; height:18px">	  Bucket *pInternalPointer		/*遍历HashTable元素*/<div class="line" id="LC111" style="padding-left:10px; height:18px">	  Bucket *pListHead;				/*双向链表表头*/<div class="line" id="LC112" style="padding-left:10px; height:18px">	  Bucket *pListTail;				/*双向链表表尾*/<div class="line" id="LC113" style="padding-left:10px; height:18px">	  Bucket **arBuckets;				/*Bucket数组*/<div class="line" id="LC114" style="padding-left:10px; height:18px">  } HashTable;<div class="line" id="LC115" style="padding-left:10px; height:18px">  <div class="line" id="LC116" style="padding-left:10px; height:18px">  ========<div class="line" id="LC117" style="padding-left:10px; height:18px">  此处为HashTable的结构图<div class="line" id="LC118" style="padding-left:10px; height:18px">  ========<div class="line" id="LC119" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC120" style="padding-left:10px; height:18px">3.神奇的数字--33<div class="line" id="LC121" style="padding-left:10px; height:18px">  见我原来的一篇博客:http://blog.csdn.net/wusuopubupt/article/details/11479869<div class="line" id="LC122" style="padding-left:10px; height:18px">  下面是PHP源码中的一段注释:<div class="line" id="LC123" style="padding-left:10px; height:18px">  /*<div class="line" id="LC124" style="padding-left:10px; height:18px">   * DJBX33A (Daniel J. Bernstein, Times 33 with Addition)<div class="line" id="LC125" style="padding-left:10px; height:18px">   *<div class="line" id="LC126" style="padding-left:10px; height:18px">   * This is Daniel J. Bernstein's popular `times 33' hash function as<div class="line" id="LC127" style="padding-left:10px; height:18px">   * posted by him years ago on comp.lang.c. It basically uses a function<div class="line" id="LC128" style="padding-left:10px; height:18px">   * like ``hash(i) = hash(i-1) * 33 + str[i]''. This is one of the best<div class="line" id="LC129" style="padding-left:10px; height:18px">   * known hash functions for strings. Because it is both computed very<div class="line" id="LC130" style="padding-left:10px; height:18px">   * fast and distributes very well.<div class="line" id="LC131" style="padding-left:10px; height:18px">   *<div class="line" id="LC132" style="padding-left:10px; height:18px">   * The magic of number 33, i.e. why it works better than many other<div class="line" id="LC133" style="padding-left:10px; height:18px">   * constants, prime or not, has never been adequately explained by<div class="line" id="LC134" style="padding-left:10px; height:18px">   * anyone. So I try an explanation: if one experimentally tests all<div class="line" id="LC135" style="padding-left:10px; height:18px">   * multipliers between 1 and 256 (as RSE did now) one detects that even<div class="line" id="LC136" style="padding-left:10px; height:18px">   * numbers are not useable at all. The remaining 128 odd numbers<div class="line" id="LC137" style="padding-left:10px; height:18px">   * (except for the number 1) work more or less all equally well. They<div class="line" id="LC138" style="padding-left:10px; height:18px">   * all distribute in an acceptable way and this way fill a hash table<div class="line" id="LC139" style="padding-left:10px; height:18px">   * with an average percent of approx. 86%.<div class="line" id="LC140" style="padding-left:10px; height:18px">   *<div class="line" id="LC141" style="padding-left:10px; height:18px">   * If one compares the Chi^2 values of the variants, the number 33 not<div class="line" id="LC142" style="padding-left:10px; height:18px">   * even has the best value. But the number 33 and a few other equally<div class="line" id="LC143" style="padding-left:10px; height:18px">   * good numbers like 17, 31, 63, 127 and 129 have nevertheless a great<div class="line" id="LC144" style="padding-left:10px; height:18px">   * advantage to the remaining numbers in the large set of possible<div class="line" id="LC145" style="padding-left:10px; height:18px">   * multipliers: their multiply operation can be replaced by a faster<div class="line" id="LC146" style="padding-left:10px; height:18px">   * operation based on just one shift plus either a single addition<div class="line" id="LC147" style="padding-left:10px; height:18px">   * or subtraction operation. And because a hash function has to both<div class="line" id="LC148" style="padding-left:10px; height:18px">   * distribute good _and_ has to be very fast to compute, those few<div class="line" id="LC149" style="padding-left:10px; height:18px">   * numbers should be preferred and seems to be the reason why Daniel J.<div class="line" id="LC150" style="padding-left:10px; height:18px">   * Bernstein also preferred it.<div class="line" id="LC151" style="padding-left:10px; height:18px">   *<div class="line" id="LC152" style="padding-left:10px; height:18px">   *<div class="line" id="LC153" style="padding-left:10px; height:18px">   *                  -- Ralf S. Engelschall <div class="line" id="LC154" style="padding-left:10px; height:18px">   */<div class="line" id="LC155" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC156" style="padding-left:10px; height:18px">  <div class="line" id="LC157" style="padding-left:10px; height:18px">4.哈希表的操作接口(省略了部分参数)<div class="line" id="LC158" style="padding-left:10px; height:18px">  初始化HashTable:int _zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction);<div class="line" id="LC159" style="padding-left:10px; height:18px">  添加新hash值:   int _zend_hash_add_or_update(HashTable *ht, const char *arKey, uint nKeyLength, void *pData)<div class="line" id="LC160" style="padding-left:10px; height:18px">  查找hash:       int zend_hash_find(const HashTable *ht, const char *arKey, uint nKeyLength, void **pData);<div class="line" id="LC161" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC162" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC163" style="padding-left:10px; height:18px">/////<div class="line" id="LC164" style="padding-left:10px; height:18px">0x03  常量<div class="line" id="LC165" style="padding-left:10px; height:18px">///// <div class="line" id="LC166" style="padding-left:10px; height:18px">1.常量的内部结构<div class="line" id="LC167" style="padding-left:10px; height:18px">  typedef struct _zend_constant {<div class="line" id="LC168" style="padding-left:10px; height:18px">	  zval value;<div class="line" id="LC169" style="padding-left:10px; height:18px">	  int flags;  /*常量标记,如 CONST_PERSISTENT | CONST_CS */<div class="line" id="LC170" style="padding-left:10px; height:18px">	  char *name;<div class="line" id="LC171" style="padding-left:10px; height:18px">	  uint name_len;<div class="line" id="LC172" style="padding-left:10px; height:18px">	  int module_number;<div class="line" id="LC173" style="padding-left:10px; height:18px">  } zend_constant;<div class="line" id="LC174" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC175" style="padding-left:10px; height:18px">2.define定义常量的过程  <div class="line" id="LC176" style="padding-left:10px; height:18px">  define的实现(定义在Zend/zend_builtin_functions.c),下面是部分核心代码:<div class="line" id="LC177" style="padding-left:10px; height:18px">  <div class="line" id="LC178" style="padding-left:10px; height:18px">  ZEND_FUNCTION(define)<div class="line" id="LC179" style="padding-left:10px; height:18px">  {<div class="line" id="LC180" style="padding-left:10px; height:18px">      /* 检查常量名是否存在 */<div class="line" id="LC181" style="padding-left:10px; height:18px">      if (zend_memnstr(name, "::", sizeof("::") - 1, name + name_len)) {<div class="line" id="LC182" style="padding-left:10px; height:18px">          zend_error(E_WARNING, "Class constants cannot be defined or redefined");<div class="line" id="LC183" style="padding-left:10px; height:18px">          RETURN_FALSE;<div class="line" id="LC184" style="padding-left:10px; height:18px">      }<div class="line" id="LC185" style="padding-left:10px; height:18px">      <div class="line" id="LC186" style="padding-left:10px; height:18px">      ... // 类常量定义 此处不做介绍<div class="line" id="LC187" style="padding-left:10px; height:18px">      <div class="line" id="LC188" style="padding-left:10px; height:18px">      c.value = *val;<div class="line" id="LC189" style="padding-left:10px; height:18px">      zval_copy_ctor(&c.value);<div class="line" id="LC190" style="padding-left:10px; height:18px">      if (val_free) {<div class="line" id="LC191" style="padding-left:10px; height:18px">              zval_ptr_dtor(&val_free);<div class="line" id="LC192" style="padding-left:10px; height:18px">      }<div class="line" id="LC193" style="padding-left:10px; height:18px">      c.flags = case_sensitive;  /* 大小写敏感 */<div class="line" id="LC194" style="padding-left:10px; height:18px">      c.name = zend_strndup(name, name_len);<div class="line" id="LC195" style="padding-left:10px; height:18px">      c.name_len = name_len+1;<div class="line" id="LC196" style="padding-left:10px; height:18px">      c.module_number = PHP_USER_CONSTANT;<div class="line" id="LC197" style="padding-left:10px; height:18px">      if (zend_register_constant(&c TSRMLS_CC) == SUCCESS) {  /*注册常量*/<div class="line" id="LC198" style="padding-left:10px; height:18px">              RETURN_TRUE;<div class="line" id="LC199" style="padding-left:10px; height:18px">      } else {<div class="line" id="LC200" style="padding-left:10px; height:18px">              RETURN_FALSE;<div class="line" id="LC201" style="padding-left:10px; height:18px">      }<div class="line" id="LC202" style="padding-left:10px; height:18px">  }<div class="line" id="LC203" style="padding-left:10px; height:18px">  <div class="line" id="LC204" style="padding-left:10px; height:18px">3.魔术常量<div class="line" id="LC205" style="padding-left:10px; height:18px">  PHP中的魔术常量,虽然叫做常量,但它们的值实际上随它们在代码中的位置而变化的。<div class="line" id="LC206" style="padding-left:10px; height:18px">  __LINE__	 	文件中的当前行号。<div class="line" id="LC207" style="padding-left:10px; height:18px">  __FILE__	 	文件的完整路径和文件名。如果用在被包含文件中,则返回被包含的文件名。<div class="line" id="LC208" style="padding-left:10px; height:18px">  __DIR__	 	文件所在的目录。如果用在被包括文件中,则返回被包括的文件所在的目录。它等价于 dirname(__FILE__)。<div class="line" id="LC209" style="padding-left:10px; height:18px">  __FUNCTION__	函数名称<div class="line" id="LC210" style="padding-left:10px; height:18px">  __CLASS__	 	类的名称。类名包括其被声明的作用区域(例如 Foo\Bar)。<div class="line" id="LC211" style="padding-left:10px; height:18px">  __TRAIT__	 	Trait 的名字。Trait 名包括其被声明的作用区域(例如 Foo\Bar)。<div class="line" id="LC212" style="padding-left:10px; height:18px">  __METHOD__	类的方法名<div class="line" id="LC213" style="padding-left:10px; height:18px">  __NAMESPACE__	当前命名空间的名称(区分大小写)。此常量是在编译时定义的(PHP 5.3.0 新增)。<div class="line" id="LC214" style="padding-left:10px; height:18px">  <div class="line" id="LC215" style="padding-left:10px; height:18px">  PHP内核会在词法解析时将这些常量的内容赋值进行替换,而不是在运行时进行分析。 举个例子:<div class="line" id="LC216" style="padding-left:10px; height:18px">  <?php </p><div class="line" id="LC217" style="padding-left:10px; height:18px">  echo __LINE__;<div class="line" id="LC218" style="padding-left:10px; height:18px">  function demo() {<div class="line" id="LC219" style="padding-left:10px; height:18px">    echo __FUNCTION__;<div class="line" id="LC220" style="padding-left:10px; height:18px">  }<div class="line" id="LC221" style="padding-left:10px; height:18px">  demo();<div class="line" id="LC222" style="padding-left:10px; height:18px">  ?><div class="line" id="LC223" style="padding-left:10px; height:18px">  PHP已经在词法解析时将这些常量换成了对应的值,以上的代码可以看成如下的PHP代码:<div class="line" id="LC224" style="padding-left:10px; height:18px">  <?php </p><div class="line" id="LC225" style="padding-left:10px; height:18px">  echo 2;<div class="line" id="LC226" style="padding-left:10px; height:18px">  function demo() {<div class="line" id="LC227" style="padding-left:10px; height:18px">      echo "demo";<div class="line" id="LC228" style="padding-left:10px; height:18px">  }<div class="line" id="LC229" style="padding-left:10px; height:18px">  demo();<div class="line" id="LC230" style="padding-left:10px; height:18px">  ?><div class="line" id="LC231" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC232" style="padding-left:10px; height:18px">  ===========<div class="line" id="LC233" style="padding-left:10px; height:18px">  此处涉及编译原理知识,需补充。<div class="line" id="LC234" style="padding-left:10px; height:18px">  ===========<div class="line" id="LC235" style="padding-left:10px; height:18px">  <div class="line" id="LC236" style="padding-left:10px; height:18px">/////<div class="line" id="LC237" style="padding-left:10px; height:18px">0x04  参考文献<div class="line" id="LC238" style="padding-left:10px; height:18px">///// <div class="line" id="LC239" style="padding-left:10px; height:18px">
<br ><div class="line" id="LC240" style="padding-left:10px; height:18px">TIPI: http://www.php-internals.com/book/?p=chapt03/03-00-variable-and-data-types<dl class="comment_item comment_topic">
<dt class="comment_head">1楼<span class="user">wusuopuBUPT<span class="ptime">昨天 14:06</span></span>
</dt>
<dd class="comment_body">本文github地址:https://github.com/wusuopubupt/phpLib/blob/master/PHP%E5%86%85%E6%A0%B8%E4%B8%AD%E7%9A%84%E5%8F%98%E9%87%8F%E5%92%8C%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B</dd>
</dl>
<div class="clear">
                 
              
              
        
            </div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div></div>
</div>
</div>
</div>
</div>
</div></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1248
24
Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

See all articles