|
Posted by Erwin Moller on 05/17/07 08:45
jmark@fastermail.com wrote:
> On May 16, 1:17 pm, Erwin Moller
> <since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
>> j...@fastermail.com wrote:
>> > I have seen some code like
>> > $value = strval($REQUEST['value']);
>>
>> > I would like to know what is the use of strval here since $_REQUEST
>> > values are strings?
>>
>> Hi,
>>
>> $_REQUEST values might as well contain arrays.
>>
>> Consider this form:
>> <form action="test.php" Method="POST">
>> <input type="checkbox" name="bla[]" value="1">1<br>
>> <input type="checkbox" name="bla[]" value="2">2<br>
>> <input type="checkbox" name="bla[]" value="3">3<br>
>> </form>
>>
>> When receiving $_POST["bla"] it contains an array.
>>
>> The programmer wanted to make sure it is a string.
>>
>> Regards,
>> Erwin Moller
>>
>> PS: I think you should avoid $_REQUEST. Just use $_POST and $_GET.
>
> But as per documentation
> http://us.php.net/manual/en/function.strval.php
>
> strval can only be used on scalars
> using strval on arrays has no effect.
> the programmer should have used is_string if its a string
good point.
Kind of useless action indeed.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|