Bug #34287 [Com]: geting the first letter of a string
| From: | p dot hu at freemail dot hu | Date: | Tue, 24 May 2011 09:39:15 +0000 |
| Subject: | Bug #34287 [Com]: geting the first letter of a string | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-160927@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=34287&edit=1
ID: 34287
Comment by: p dot hu at freemail dot hu
Reported by: stuk88 at gmail dot com
Summary: geting the first letter of a string
Status: No Feedback
Type: Bug
Package: MySQL related
Operating System: Win XP
PHP Version: 5CVS-2005-08-28 (CVS)
Block user comment: N
Private report: N
New Comment:
I just ran into a similar problem. One script returned a strange first
character that was not visible in a browser when utf8 encoding was
selected, but an other script that used this as an input did not work
well.
I tried to convert the string, changed some settings in mysql where the
result came from, but nothing helped.
After several hours of head scratchig it turned out that the script
itself was written with utf8 encoding. Changing it to ansi solved the
problem. (Thanks Notepad++) The result string started correctly from
char[0].
Previous Comments:
------------------------------------------------------------------------
[2005-09-05 01:00:05] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2005-08-28 20:09:37] sniper@php.net
Then provide a reproducing script that actually does NOT work for you!!
The lines you provided work just fine.
------------------------------------------------------------------------
[2005-08-28 18:46:32] stuk88 at gmail dot com
it dosent...
i used a mysql result array var and i tryed to see the first letter and
it doesnt worked with {0}
and the substr($var['title'], 1, 2); (for exsamle) returned the first
letter but the
substr($var['title'], 0, 1);
didnt...
------------------------------------------------------------------------
[2005-08-28 16:30:01] sniper@php.net
Works fine.
------------------------------------------------------------------------
[2005-08-28 14:12:03] stuk88 at gmail dot com
Description:
------------
When i try to see the first letter of a string on php5 like
$var{0} - it returns an empty string...
and when i use substr i need to start the string from 1 (not 0) and
finish on 2 (not 1) - is it a bug or a php 5 improvment?
it seems to be a problem in all the php 5 based servers
Reproduce code:
---------------
$var = "my name is stas<br>";
echo $var{0};
or
$var = "my name is stas";
echo substr($var,0,1);
Expected result:
----------------
m
m
Actual result:
--------------
---nothing---
its showing an empty page with nothing in it
and just when i use the substr with the first letter 1 and end 2 its
returns me the right thing...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=34287&edit=1