Variables are empty only in fwrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello, when I pass a variable whose value originally came from $_GET
or $_REQUEST to fwrite, fwrite behaves as if it was passed an empty
string. Note that the file is successfully opened and written to by
the script, but the variable that originally came from $_GET does not
have its value interpolated in the text file, even though it does get
interpolated in the echo().

---- Code ----
<?
$meh = $_GET["q"];
$writeline = ":" . $meh . ":" . strlen($meh) . PHP_EOL;
echo ( $writeline );

$fp = fopen("/tmp/wtf.log","w+");
fwrite($fp, $writeline );
fclose($fp);

var_dump($writeline);
?>

---- Request ----

/search.php?q=meh123

---- Response --- ( expected )

:meh123:6 string(10) ":meh123:6 "

---- Contents of /tmp/wtf.log ----
::0

Some sort of security setting in php.ini maybe? If so, I'm not only
curious in how to fix it but also how this actually happens. Does the
value assigned to $writeline not get immediately evaluated? I mean,
does $writeline "know" it contains variables from elsewhere, instead
of just containing a string of chars?

Thanks!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux