[FX.php List] question about returned result array

Kevin Futter kfutter at sbc.melb.catholic.edu.au
Mon Mar 19 21:54:52 MDT 2007


On 20/3/07 2:28 PM, "Alex Gates" <alex at gandrpublishing.com> wrote:

>> 
>> Not sure how directly this relates to your problem, but it's pertinent to
>> remember that *everything* passed via GET or POST is considered a string;
>> the formal concept of a number type just doesn't apply here. You'd probably
>> have to convert the type to a number in PHP before submitting it to FM. By
>> the way, %22 is URL encoding for ' " ' (double-quote).
>> 
> 
> Thanks, Kevin-
> 
> I never realized you could specify the type of variable in php - I
> thought $foo could be a string or a number.
> 
> Does it cause problems that I was trying to use a session variable?
> 
> Even though I have my original problem resolved (thanks to a fx.php
> upgrade) I'm still interested.
> 
> 
> How can I convert the type to a number?

You know, I wasn't really sure. PHP has dynamic typing, so that's what we
all exploit. I've never had to force a variable type in PHP before, but I
had a suspicion it can be done, so I looked it up.

(By the way, I use a great Mac app called PHPfi for searching the PHP manual
locally: http://www.artissoftware.com/phpfi/index.html)


The answer is: settype()

Example from manual:

<?php
$foo = "5bar"; // string
$bar = true;   // boolean

settype($foo, "integer"); // $foo is now 5   (integer)
settype($bar, "string");  // $bar is now "1" (string)
?>

Of course, submitting data into FM introduces a another layer to deal with,
but it should just take whatever input it's given - provided it meets basic
spec - and make it whatever type the field is set to. By that I mean, your
variables may be sent to FM as strings, but when FM pops the string "67"
into a number field, it becomes a number. In other words, it shouldn't make
any difference in theory to FM.

I'm not sure if session variables behave the same way as GET and POST
variables. In fact I'd suggest they don't, but perhaps someone else on the
list has more insight there.

-- 
Kevin Futter
Webmaster, St. Bernard's College
http://www.sbc.melb.catholic.edu.au/




#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal
#####################################################################################

This e-mail and any attachments may be confidential. You must not disclose or use the information in this e-mail if you are not the intended recipient. If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies. The College does not guarantee that this e-mail is virus or error free.  The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not. The content and opinions in this e-mail are not necessarily those of the College.


More information about the FX.php_List mailing list