note 84240 rejected from language.types.string by danbrown

From: Date: Wed, 09 Jul 2008 13:43:59 +0000
Subject: note 84240 rejected from language.types.string by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141304@lists.php.net to get a copy of this message
Note Submitter: nullhility at gmail dot com ---- 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 ?>

« previous php.notes (#141304) next »