php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46214 strpos() returns varying results
Submitted: 2008-10-01 18:11 UTC Modified: 2008-10-07 19:46 UTC
From: dimedrol at tut dot by Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.6 OS: GNU/Linux i686 2.6.9
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dimedrol at tut dot by
New email:
PHP Version: OS:

 

 [2008-10-01 18:11 UTC] dimedrol at tut dot by
Description:
------------
When I run short script below I every time receive different values in output. It may print 7 and may print 11. PHP-file has encoding cp-1251.

Here's version info from my webserver

-bash-2.05b$ /usr/sbin/httpd -V
Server version: Apache/2.0.63
Server built: Jul 22 2008 23:09:16
Architecture: 32-bit
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D HTTPD_ROOT="/usr/local/apache"
-D SUEXEC_BIN="/usr/local/apache/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

Reproduce code:
---------------
<?php
print(strpos('&#1074;&#1072;&#1089;&#1103;12hello[b]','[b]'));
?>

it contains cyrillic characters. If I replace them with latin ones everything works fine

Expected result:
----------------
I expect 11 to be printed

Actual result:
--------------
Actual results is sometimes 11 and sometimes 7. 7 looks like cyrillic characters are simply omitted during calculation.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-01 18:13 UTC] dimedrol at tut dot by
In my sample code cyrillic characters were replaced by unicode escape sequences. Please note that originally they were single-byte cp-1251 characters.
 [2008-10-07 12:25 UTC] jani@php.net
Yes, use mbstring. No bug here.
 [2008-10-07 19:46 UTC] dimedrol at tut dot by
I would underline, that mbstring is intended for multibyte characters whereas I use single-byte encoding CP-1251 so why would I need mbstring then?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 12:01:28 2024 UTC