Re: Variables are empty only in fwrite
| From: | Stuart Dallas | Date: | Thu, 15 Mar 2012 20:18:42 +0000 |
| Subject: | Re: Variables are empty only in fwrite | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-317048@lists.php.net to get a copy of this message | ||
On 15 Mar 2012, at 20:07, Larry wrote:
> On Thu, Mar 15, 2012 at 4:03 PM, Matijn Woudt <tijnema@gmail.com> wrote:
>> On Thu, Mar 15, 2012 at 8:41 PM, Larry <lrrrgg@gmail.com> wrote:
>>> On Thu, Mar 15, 2012 at 2:57 PM, Matijn Woudt <tijnema@gmail.com> wrote:
>>>> On Thu, Mar 15, 2012 at 7:51 PM, Larry <lrrrgg@gmail.com> wrote:
>>>>> On Thu, Mar 15, 2012 at 12:21 PM, Matijn Woudt <tijnema@gmail.com> wrote:
>>>>>> On Thu, Mar 15, 2012 at 4:59 PM, Larry <lrrrgg@gmail.com> wrote:
>>>>>>> On Thu, Mar 15, 2012 at 11:53 AM, Daniel P. Brown
>>>>>>> <daniel.brown@parasane.net> wrote:
>>>>>>>> On Thu, Mar 15, 2012 at 11:30, Larry <lrrrgg@gmail.com>
>>>>>>>> wrote:
>>>>>>>>> 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);
>>>>>>>>> ?>
>>>
>>> Yes I tried using $_GET['q'] directly to no avail. However, you found
>>> a clue! apache error.log is giving this:
>>> PHP Notice: Undefined index: q in /var/www/test/search.php on line 2
>>>
>>> Strange b/c I am obtaining and using that value successfully in echo()!
>>
>> Well.. That seems pretty buggy, I guess it's a bug in PHP. Try
>> changing q in something else, and maybe you want to submit a bug
>> report to PHP?
>
> Changing the index name didn't help. I think I will submit a bug,
> after a bit more scrutiny of my php.ini to make sure there isn't some
> restriction in there. This is a default ubuntu apache/php.ini though.
> Thanks again.
Is that definitely the exact code you're running? Nothing added, nothing removed? I ask because
it works for me...
http://dev.3ft9.com/php/larry/index.php?q=123
What version of PHP are you using, and do you have any non-standard extensions involved?
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/