PHP string length without strlen ()

Just by looking at the latest version of PHP coding standards, and something caught my attention:

http://svn.php.net/viewvc/php/php-src/trunk/CODING_STANDARDS?revision=296679&view=markup

Coding Standard # 4 states that "When writing string-related functions, be sure to remember that PHP contains a property for the length of each line and that it should not be calculated using strlen () ..."

I ALWAYS used strlen, and maybe it's only late, but how do you access the built-in string length property in PHP?

+3
source share
3 answers

C, PHP. C \0, PHP \0 , .

+10

, PHP C PHP-.

========================
PHP
============ ============
, , PHP. PHP v3.0, , . 4 .

, , , , PHP.

, , - .

+1

zval ( C), Z_STRLEN (your_zval) . zend_operators.h 398 (PHP 5.4):

#define Z_STRLEN(zval)          (zval).value.str.len
0

Source: https://habr.com/ru/post/1774454/


All Articles