Home > Backend Development > PHP Tutorial > c中的strlen函数字符''来判断字符串是否结束,那php呢?

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

WBOY
Release: 2016-06-20 12:36:19
Original
1165 people have browsed it

  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;};
Copy after login

然后你就懂了。

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

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

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template