note 5665 modified in Chr by ronabop
| From: | ronabop@php.net | Date: | Fri, 11 Aug 2000 17:23:40 +0000 |
| Subject: | note 5665 modified in Chr by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-1319@lists.php.net to get a copy of this message | ||
Learn from my mistake:
Do not expect this to work!
$c_question = chr(63);
$v_out = sprintf("<%cphp\n", $c_question);
//... more stuff being sprintf'd into v_out here ...
$v_out = sprintf("%s%c>\n", $v_out, $c_question);
$v_fp = fopen("foofile", "w");
if ($v_fp)
{
fwrite($v_fp, $v_out, strlen($v_out));
fclose($v_fp);
}
When I did this, foofile contained <NUL NUL NUL NUL NUL>.
I spun my wheels quite awhile looking at fputs, fwrite to verify I was calling those functions
correctly.
My mistake was using $c_question = chr(63) instead of
$c_question = 63 (correct). Then everything worked fine.
http://www.php.net/manual/function.chr.php