Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP string length [duplicate]

PHP coding standards say:

... PHP holds the length property of each string, and that it shouldn't be calculated with strlen(). Write your functions in a such a way so that they'll take advantage of the length property, both for efficiency and in order for them to be binary-safe. ...

How can I access this length property? Or do I misunderstand it?

like image 254
koubic Avatar asked Feb 20 '23 12:02

koubic


1 Answers

As Ignacio mentioned in another post:

They're talking about the C function, not the PHP function. The C function will stop counting after the first \0, but PHP strings can contain \0 elsewhere other than the end.

That document is most likely about how to extend PHP's engine, rather than programming in PHP itself.

like image 100
hohner Avatar answered Feb 28 '23 16:02

hohner