php-general Digest 25 Jun 2013 06:03:47 -0000 Issue 8277 Topics (messages 321468 through 321479):
Is it possible??? 321468 by: Karl-Arne Gjersøyen 321469 by: Stuart Dallas 321470 by: raphael khaiat 321471 by: Karl-Arne Gjersøyen 321472 by: Stuart Dallas 321473 by: nobs.nobswolf.info 321474 by: Sachin Raut 321475 by: Carlos Medina 321476 by: Maciek Sokolewicz 321477 by: Carlos Medina 321478 by: Marco Behnke 321479 by: php.nobswolf.info Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net ----------------------------------------------------------------------
--- Begin Message ---$item_amount_in_store = 223; $update_amount = 7; $update_item_amount_in_store += $update_amount; $update_amoint_in_store is now 227; Why? That should be 230! Karl
--- End Message ---
--- Begin Message ---On 24 Jun 2013, at 12:59, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote: > $item_amount_in_store = 223; > $update_amount = 7; > $update_item_amount_in_store += $update_amount; > $update_amoint_in_store is now 227; > > Why? That should be 230! Because you're using $item_amount_in_store and $update_item_amount_in_store as if PHP should know you mean the same thing. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/
--- End Message ---
--- Begin Message ---Hi, Shouldn't it be: $item_amount_in_store = 223; $update_amount = 7; $item_amount_in_store += $update_amount; $update_amoint_in_store is now 227; The 3rd line seems wrong as you didn't use the same variable. -- Raphaël Khaïat 06.72.89.57.29 On Mon, Jun 24, 2013 at 1:59 PM, Karl-Arne Gjersøyen <karlar...@gmail.com>wrote: > $item_amount_in_store = 223; > $update_amount = 7; > $update_item_amount_in_store += $update_amount; > $update_amoint_in_store is now 227; > > Why? That should be 230! > > Karl >
--- End Message ---
--- Begin Message ---Error in my last post This is corrected: $item_amount_in_store = 223; $update_amount = 7; $item_amount_in_Store += $update_amount; It show the result = 227 and not 230. Why is this happen? Karl ---------- Forwarded message ---------- From: Karl-Arne Gjersøyen <karlar...@gmail.com> Date: 2013/6/24 Subject: Is it possible??? To: PHP Mailinglist <php-gene...@lists.php.net> $item_amount_in_store = 223; $update_amount = 7; $update_item_amount_in_store += $update_amount; $update_amoint_in_store is now 227; Why? That should be 230! Karl -- Hjemmeside: http://www.karl-arne.name/
--- End Message ---
--- Begin Message ---On 24 Jun 2013, at 13:02, Karl-Arne Gjersøyen <karlar...@gmail.com> wrote: > Error in my last post This is corrected: > > $item_amount_in_store = 223; > $update_amount = 7; > $item_amount_in_Store += $update_amount; > > It show the result = 227 and not 230. Why is this happen? Something else is going on to give you 227, but variable names are case sensitive which is why you're not getting what you expect. <?php $item_amount_in_store = 223; $update_amount = 7; $item_amount_in_Store += $update_amount; var_dump($item_amount_in_store); var_dump($item_amount_in_Store); ?> Output: int(223) int(7) -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ > ---------- Forwarded message ---------- > From: Karl-Arne Gjersøyen <karlar...@gmail.com> > Date: 2013/6/24 > Subject: Is it possible??? > To: PHP Mailinglist <php-gene...@lists.php.net> > > > $item_amount_in_store = 223; > $update_amount = 7; > $update_item_amount_in_store += $update_amount; > $update_amoint_in_store is now 227; > > Why? That should be 230! > > Karl > > > > -- > Hjemmeside: http://www.karl-arne.name/
--- End Message ---
--- Begin Message ---You should give a complete programm so we can run exactly the same you do, like this: <?php $item_amount_in_store = 223; print ("$item_amount_in_store"); $update_amount = 7; $item_amount_in_store += $update_amount; print (" + $update_amount = $item_amount_in_store "); ?> which gives this result: 223 + 7 = 230
--- End Message ---
--- Begin Message ---variables are case-sensitive. $item_amount_in_store is different from $item_amount_in_Store 1st variable contains all lowercase characters, while the 2nd one contains "S" uppercase character. happy coding sachin On Mon, Jun 24, 2013 at 5:32 PM, Karl-Arne Gjersøyen <karlar...@gmail.com>wrote: > Error in my last post This is corrected: > > $item_amount_in_store = 223; > $update_amount = 7; > $item_amount_in_Store += $update_amount; > > It show the result = 227 and not 230. Why is this happen? > > Karl > > ---------- Forwarded message ---------- > From: Karl-Arne Gjersøyen <karlar...@gmail.com> > Date: 2013/6/24 > Subject: Is it possible??? > To: PHP Mailinglist <php-gene...@lists.php.net> > > > $item_amount_in_store = 223; > $update_amount = 7; > $update_item_amount_in_store += $update_amount; > $update_amoint_in_store is now 227; > > Why? That should be 230! > > Karl > > > > -- > Hjemmeside: http://www.karl-arne.name/ >
--- End Message ---
--- Begin Message ---Hi Karl, i dont know what you want to do. But i can say: The $item_amount_in_store variable is not the same to $item_amount_in_Store (case sensitive). It work for me... Regards Carlos Medina Am 24.06.2013 14:02, schrieb Karl-Arne Gjersøyen: > Error in my last post This is corrected: > > $item_amount_in_store = 223; > $update_amount = 7; > $item_amount_in_Store += $update_amount; > > It show the result = 227 and not 230. Why is this happen? > > Karl > > ---------- Forwarded message ---------- > From: Karl-Arne Gjersøyen <karlar...@gmail.com> > Date: 2013/6/24 > Subject: Is it possible??? > To: PHP Mailinglist <php-gene...@lists.php.net> > > > $item_amount_in_store = 223; > $update_amount = 7; > $update_item_amount_in_store += $update_amount; > $update_amoint_in_store is now 227; > > Why? That should be 230! > > Karl > > >
--- End Message ---
--- Begin Message ---On 24-6-2013 14:27, n...@nobswolf.info wrote:You should give a complete programm so we can run exactly the same you do, like this: <?php $item_amount_in_store = 223; print ("$item_amount_in_store");Please please please please don't do this!First of all, I don't know why you would use the print *function* when you can also use the echo language construct (better and faster). But that's not that important; it's not bad to use it, just imo a bit ugly (pet peeve ;)).But more importantly:"$variable" is completely and utterly useless. You're basically creating a string, interpolating a variable in it, and adding no more content. This is effectively the same as saying:print("".$var."") Does that look right to you? To me it looks... wrong... Why not just a simple: echo $var; or print($var) if you really must.And if you really really must cast the variable to a string, you can always use the explicit:(string) $var$update_amount = 7; $item_amount_in_store += $update_amount; print (" + $update_amount = $item_amount_in_store "); ?> which gives this result: 223 + 7 = 230
--- End Message ---
--- Begin Message ---Amen! Am 24.06.2013 18:17, schrieb Maciek Sokolewicz: > On 24-6-2013 14:27, n...@nobswolf.info wrote: >> You should give a complete programm so we can run exactly >> the same you do, like this: >> >> <?php >> >> $item_amount_in_store = 223; >> >> print ("$item_amount_in_store"); > Please please please please don't do this! > > First of all, I don't know why you would use the print *function* when > you can also use the echo language construct (better and faster). But > that's not that important; it's not bad to use it, just imo a bit ugly > (pet peeve ;)). > > But more importantly: > "$variable" is completely and utterly useless. You're basically creating > a string, interpolating a variable in it, and adding no more content. > This is effectively the same as saying: > print("".$var."") > Does that look right to you? To me it looks... wrong... > > Why not just a simple: > echo $var; > or > print($var) if you really must. > > And if you really really must cast the variable to a string, you can > always use the explicit: > (string) $var > >> >> $update_amount = 7; >> $item_amount_in_store += $update_amount; >> >> print (" + $update_amount = $item_amount_in_store "); >> ?> >> >> which gives this result: >> >> 223 + 7 = 230 >> >
--- End Message ---
--- Begin Message ---Am 24.06.2013 18:17, schrieb Maciek Sokolewicz:On 24-6-2013 14:27, n...@nobswolf.info wrote:You should give a complete programm so we can run exactly the same you do, like this: <?php $item_amount_in_store = 223; print ("$item_amount_in_store");Please please please please don't do this! First of all, I don't know why you would use the print *function* when you can also use the echo language construct (better and faster). Butread and learn http://de2.php.net/manual/en/function.print.php print is not actually a real function (it is a language construct) -- Marco Behnke Dipl. Informatiker (FH), SAE Audio Engineer Zend Certified Engineer PHP 5.3 Tel.: 0174 / 9722336 e-Mail: ma...@behnke.biz Softwaretechnik Behnke Heinrich-Heine-Str. 7D 21218 Seevetal http://www.behnke.bizsmime.p7s
Description: S/MIME Kryptografische Unterschrift
--- End Message ---
--- Begin Message ---On Mon, Jun 24, 2013 at 06:17:33PM +0200, Maciek Sokolewicz wrote: > Please please please please don't do this! 1) You did not answer the question, nor giving any related information. 2) This was debug-output. I see not point in optimizing. 3) print is language construct, just as is echo 4) the argument to print is converted to string anyways, so ... 5) the quotes around a single variable allows fast adding helping text while debugging; so it was on purpose You are not the only one that has a coding style for a reason. So back to topic: I guess the case-sensitive variables were the most helpfull hint for the thread-starter? If not please send a complete example of your code.
--- End Message ---