FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » integer and string what's the difference ?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: integer and string what's the difference ? [message #175863 is a reply to message #175861] Tue, 01 November 2011 18:48 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Tue, 01 Nov 2011 11:23:39 -0400, richard wrote:

> On Tue, 1 Nov 2011 06:19:01 -0700 (PDT), gaoqiang wrote:
>
>> 1 <?php
>> 2 require_once("config.php");
>> 3 $now=time();
>> 4 $value="abcd";
>> 5 $key="1234";
>> 6
>> 7 $mem_server="localhost";
>> 8 $mem_port=11211;
>> 9 $memc=new Memcached;
>> 10 $memc->addServer($mem_server,$mem_port); 11
>> $memc->set($key,$value);
>> 12 $keys=array();
>> 13 array_push($keys, 1234);
>> 14 $rsts=$memc->getMulti($keys);
>> 15 var_dump($rsts);
>> 16 ?>

> An integer is any numeric value.

Crap. An integer is any whole number. fractional values eg 1/2, 1/4,
567/24 etc are not integers, but they are numbers.

> Where some will argue that an integer is any whole number like 0 or 1.
> But is "1" the same as 1? No it is not.
>
> I once came across a web page that asked this simple question: When does
> '1'+'1'='11'?
> Notice the quotes.
> in computer math 1+1=2.
> But '1'+'1'='11'

Totally irrelevant. The OP clearly knows the difference between strings
and integers.

> In your code above, check line 13.
> In line 5 you defined $key="1234".
> In line 13, you are treating this value as an integer, not a string as
> you defined it.

>> 5 $key="1234";
>> 13 array_push($keys, 1234);

What on earth are you talking about? line 5 defines $key, line 13 uses
$keys, 2 totally different variables.

Richard, stop trying to debug people's code, you really have no idea what
you're talking about most of the time .... which I guess is nothing new.

Rgds

Denis McMahon
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: missing variable
Next Topic: Stats comp.lang.php (last 7 days)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Oct 06 06:24:50 GMT 2024

Total time taken to generate the page: 0.04854 seconds