note 84240 added to language.types.string
| From: | nullhility at gmail dot com | Date: | Fri, 04 Jul 2008 16:51:45 +0000 |
| Subject: | note 84240 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141177@lists.php.net to get a copy of this message | ||
In response to sassospicco:
When you set the character to null it also changed the type to null, other users should note that if
you want to set characters to null in this fashion that you should use an escape sequence to keep
the variable as type string. Here's sassospicco's altered code with the null character
(instead of NULL type), all output is as desired.
<?php
$a = 'AB';
echo strlen($a)."\n"; // 2
// Ok so far
$a[1] = "\x00";
echo strlen($a)."\n"; // 2
// The second character still exists...
var_dump($a); // string(2) "A"
echo ord($a[1]); //ASCII value: 0
?>
----
Server IP: 117.104.160.194
Probable Submitter: 124.186.94.4
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- https://master.php.net/note/edit/84240
Del: integrated -- https://master.php.net/note/delete/84240/integrated
Del: useless -- https://master.php.net/note/delete/84240/useless
Del: bad code -- https://master.php.net/note/delete/84240/bad+code
Del: spam -- https://master.php.net/note/delete/84240/spam
Del: non-english -- https://master.php.net/note/delete/84240/non-english
Del: in docs -- https://master.php.net/note/delete/84240/in+docs
Del: other reasons-- https://master.php.net/note/delete/84240
Reject -- https://master.php.net/note/reject/84240
Search -- https://master.php.net/manage/user-notes.php