I'm using PHP 7.2.11 on my machine that runs on Windows 10 Home Single Language 64-bit Operating System.
I tried below codes :
Code Snippet No. 1
<?php
$str = 'abc\0def';
echo strlen($str); // Outputs 8
?>
Code Snippet No. 2
<?php
$str = "abc\0def";
echo strlen($str); // Outputs 7
?>
I'm not understanding why the same function is producing two different outputs for the same string? One time it gives output 8
and another time 7
Why so?
Whether the function strlen()
is binary-safe and multibyte-safe or not? The PHP manual hasn't mentioned these details on the respective function's page.
strlen
on"\0"
still returns one, and prints nothing.