PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

c中的strlen函数字符''来判断字符串是否结束,那php呢?

原创
2016-06-20 12:36:19 837浏览

  c中的strlen函数字符'\0'来判断字符串是否结束,那php呢?


回复讨论(解决方案)

php 的变量是一个 C 语言结构,

能详细解释一下么?不太懂

The string in PHP is implemented as an array of bytes and an integer indicating the length of the buffer.

php是用c++写的,应该也是用"\n"吧

php的变量结构如下:

typedef struct _zval_struct zval;typedef union _zvalue_value {    long lval;                 /* long value */    double dval;               /* double value */    struct {                   /* string type */        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;};

然后你就懂了。

php变量有保存字符串长度,所以不需要用符号判断

谢谢各位!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。