| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2019-06-03 18:48 UTC] mishamosher at gmail dot com
 Description:
------------
I am trying this simple code:
<?php
echo substr("/es", 0, 1);
?>
I expect to see a "/" as a result, but I get "�" instead.
PHP is running in an entirely 64-bit environment.
 - Windows 10 1903
 - PHP 7.2.19 (as an apache module)
 - Apache 2.4.39
Running PHP from the console (php.exe -f script.php) functions properly.
Test script:
---------------
<?php
echo substr("/es", 0, 1);
?>
Expected result:
----------------
"/"
Actual result:
--------------
"�"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 00:00:01 2025 UTC | 
I tested it on Windows using the following script: var_dump( substr("/es", 0, 1) ); var_dump( substr("\xEF\xBB\xBF/es", 0, 1) ); Output: string(1) "/" string(1) "�" In general try using var_dump() on the source string. It will report the byte length, so you will notice invisible characters.Please run the following variation of your script, and report the results: <?php $in = "/es"; $out = substr($in, 0, 1); var_dump(bin2hex($in), bin2hex($out)); ?>