Re: [PHP] Assignment in Conditional - How are they evaluated?

2009-10-29 Thread Eddie Drapkin
On Thu, Oct 29, 2009 at 10:23 AM, Martin Scotta wrote: > On Thu, Oct 29, 2009 at 11:11 AM, Robert Cummings wrote: > >> Ashley Sheridan wrote: >> >>> On Thu, 2009-10-29 at 13:58 +, Mark Skilbeck wrote: >>> >>>  How is the following evaluated: [code] if ($data = somefunc()) ... >>

Fwd: [PHP] Assignment in Conditional - How are they evaluated?

2009-10-29 Thread Martin Scotta
On Thu, Oct 29, 2009 at 11:11 AM, Robert Cummings wrote: > Ashley Sheridan wrote: > >> On Thu, 2009-10-29 at 13:58 +, Mark Skilbeck wrote: >> >> How is the following evaluated: >>> >>> [code] >>> if ($data = somefunc()) ... >>> [/code] >>> >>> Ignoring the 'assignment inside condition' argume

Re: [PHP] Assignment in Conditional - How are they evaluated?

2009-10-29 Thread Robert Cummings
Ashley Sheridan wrote: On Thu, 2009-10-29 at 13:58 +, Mark Skilbeck wrote: How is the following evaluated: [code] if ($data = somefunc()) ... [/code] Ignoring the 'assignment inside condition' arguments, is the return value of somefunc() assigned to $data, and then $data's value is eval

Re: [PHP] Assignment in Conditional - How are they evaluated?

2009-10-29 Thread Martin Scotta
On Thu, Oct 29, 2009 at 10:58 AM, Mark Skilbeck wrote: > How is the following evaluated: > > [code] > if ($data = somefunc()) ... > [/code] > > Ignoring the 'assignment inside condition' arguments, is the return value > of somefunc() assigned to $data, and then $data's value is evaluated (to > tru

Re: [PHP] Assignment in Conditional - How are they evaluated?

2009-10-29 Thread Ashley Sheridan
On Thu, 2009-10-29 at 13:58 +, Mark Skilbeck wrote: > How is the following evaluated: > > [code] > if ($data = somefunc()) ... > [/code] > > Ignoring the 'assignment inside condition' arguments, is the return > value of somefunc() assigned to $data, and then $data's value is > evaluated (t

[PHP] Assignment in Conditional - How are they evaluated?

2009-10-29 Thread Mark Skilbeck
How is the following evaluated: [code] if ($data = somefunc()) ... [/code] Ignoring the 'assignment inside condition' arguments, is the return value of somefunc() assigned to $data, and then $data's value is evaluated (to true or false), or is the actual assignment tested (does the assignment

[PHP] Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread tedd
At 9:10 AM +1100 12/23/08, Clancy wrote: Schlossnagle (in "Advanced PHP Programming") advises: $i = 0; while ($i < $j) { ++$i; } rather than: $i = 0; while ($i < $j) { ... $i++; } as the former apparently uses less m

Re: [PHP] assignment

2004-12-11 Thread Chris
That's a variable variable name. http://us2.php.net/manual/en/language.variables.variable.php So $temp3 = 'valueoftemp3'; $temp2 = 'temp3'; $temp = $$temp2; $$temp2 === $temp3; Song Ken Vern wrote: Hi, Tried searching for what this $$ operator means. But can't get the right results by using $$ a

Re: [PHP] assignment

2004-12-11 Thread Jason Wong
On Friday 10 December 2004 12:02, Song Ken Vern wrote: > Tried searching for what this $$ operator means. > But can't get the right results by using $$ as search string in php manual. > > $temp = $$temp2; Search for "variable variables" > Is this an array assignment? No, but in most cases where

Re: [PHP] assignment

2004-12-11 Thread Ryan King
On Dec 9, 2004, at 10:02 PM, Song Ken Vern wrote: Hi, Tried searching for what this $$ operator means. But can't get the right results by using $$ as search string in php manual. $temp = $$temp2; Is this an array assignment? No, its a variable varible: http://us2.php.net/manual/en/language.variab

Re: [PHP] assignment

2004-12-11 Thread Sebastian
variables variable? http://us2.php.net/manual/en/language.variables.variable.php - Original Message - From: "Song Ken Vern" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 09, 2004 11:02 PM Subject: [PHP] assignment > Hi, > >

[PHP] assignment

2004-12-11 Thread Song Ken Vern
Hi, Tried searching for what this $$ operator means. But can't get the right results by using $$ as search string in php manual. $temp = $$temp2; Is this an array assignment? Thanx. Ken -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Assignment operator questions

2003-05-31 Thread Joe Stump
: Friday, May 30, 2003 11:47 AM To: [EMAIL PROTECTED] Subject: [PHP] Assignment operator questions Is it possible to do the following in PHP a = b = c; Which in C, for instance would set b and a equal to c. Thanks. Andrew. -- PHP General Mailing List (http://www.php.net/) To unsubscr

[PHP] Assignment operator questions

2003-05-31 Thread Andrew D. Luebke
Is it possible to do the following in PHP a = b = c; Which in C, for instance would set b and a equal to c. Thanks. Andrew. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] assignment by reference bug? (update)

2002-12-21 Thread reynardmh
just a little update after playing arround with this stuffs, I think this behavior happens when there is nothing else pointing to variable $a. so for example, this works also: $tmp =& $a; $a =& $a->next; I'm wondering how php does garbage collection? does it immediately delete variables th

[PHP] assignment by reference bug?

2002-12-21 Thread reynardmh
hi, I just found this behavior when trying to implement a linked list with php. In linked list it's common to say: $a =& $a->next; when traversing the list. but this doesn't work (it gives segmentation fault when trying to access the $head->next object (after the above assignment). but this w

[PHP] assignment to $this inside constructor

2002-12-04 Thread Filippo Veneri
Let's begin with a small code snippet: class A { function A( $selector ) { switch( $selector ) { case 1: $obj = new A_1(); break; case 2: $obj = new A_2(); break; ... } $this = $obj; } } class A_1 { ... } class A_2 { .

Re: [PHP] Assignment operator proposal

2002-03-21 Thread Rasmus Lerdorf
> Please note, there are many German PHP developers. Most of them are > not so stupid ... Oh, I don't know about that. I have met a bunch of them... ;) -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Assignment operator proposal

2002-03-21 Thread Bogdan Stancescu
[EMAIL PROTECTED] wrote: > I think this is a nice idea for php8 (or some release, I´ll never have > to use) > The main thing in using php is that it is close to c. > As there are so many new functions, some of them are not really > necessary, > I would not prefer shortcuts like these. Who shoul

Re: [PHP] Assignment operator proposal

2002-03-21 Thread Bogdan Stancescu
Egon Schmid wrote: >From: "Enrico Weigelt" <[EMAIL PROTECTED]> > > >Please note, there are many German PHP developers. Most of them are >not so stupid ... > I must say I fail to understand both the meaning and the reason for the harsness in your reply. Bogdan -- PHP General Mailing List (h

Re: [PHP] Assignment operator proposal

2002-03-20 Thread Egon Schmid
From: "Enrico Weigelt" <[EMAIL PROTECTED]> > On Thu, Mar 21, 2002 at 12:36:26AM +0200, Bogdan Stancescu wrote: > > > Hi all! > > > > I'd like to hear from a single one of you who isn't tired of code similar to > > i'm solving this with some little knowledge of shortcuts evaluation ... > > > > i

Re: [PHP] Assignment operator proposal

2002-03-20 Thread heinisch
At 21.03.2002 00:36, you wrote: >Hi all! > >I'd like to hear from a single one of you who isn't tired of code similar to > > if (!$whatever) { >$whatever=something; > } >?> > >or else > > if ($whatever) > { >$somethingelse=$whatever; > } >?> > >How about a new asignment operator whic

RE: [PHP] Assignment operator proposal

2002-03-20 Thread Kevin Stone
[EMAIL PROTECTED]] Sent: Wednesday, March 20, 2002 3:36 PM To: [EMAIL PROTECTED] Subject: [PHP] Assignment operator proposal Hi all! I'd like to hear from a single one of you who isn't tired of code similar to or else How about a new asignment operator which would shut up all those Pyt

Re: [PHP] Assignment operator proposal

2002-03-20 Thread Enrico Weigelt
On Thu, Mar 21, 2002 at 12:36:26AM +0200, Bogdan Stancescu wrote: > Hi all! > > I'd like to hear from a single one of you who isn't tired of code similar to i'm solving this with some little knowledge of shortcuts evaluation ... > if (!$whatever) { >$whatever=something; > } > ?> (($wh

[PHP] Assignment operator proposal

2002-03-20 Thread Bogdan Stancescu
Hi all! I'd like to hear from a single one of you who isn't tired of code similar to or else How about a new asignment operator which would shut up all those Python enthusiasts - let's say the new operator would be caret - and we could replace the first example with and the second exam

Re: [PHP] assignment operator works for comparison??

2001-04-11 Thread Renze Munnik
Dan wrote: > > This confused me for awhile, because the single equal sign seemed to work > for comparison, but created inexplicable errors in my programs. It seems > strange to me that a successful variable value assignment does not return > true. > > example: > > > $shiny = 1; > if($shiny

Re: [PHP] assignment operator works for comparison??

2001-04-11 Thread Harshdeep S Jawanda
Hi, Dan wrote: > > > if($shiny = 0){ > > This does not compare anyting, it assigns 0 to $shiny > > yes i know, but shouldnt this operation return true? No, it doesn't return true. The "=" operator returns the value of the expression on its right hand side. Therefore, the statement given above

Re[2]: [PHP] assignment operator works for comparison??

2001-04-11 Thread Maxim Derkachev
Hello Dan, Wednesday, April 11, 2001, 1:29:22 AM, you wrote: >> >> > if($shiny = 0){ >> This does not compare anyting, it assigns 0 to $shiny D> yes i know, but shouldnt this operation return true? No. This operator returns the value assigned (0 in this case, which is false). This expression

Re: [PHP] assignment operator works for comparison??

2001-04-10 Thread Yasuo Ohgaki
> if($shiny = 0) This line is the same as if ((shiny = 0) == TRUE) It's common error with PHP and C. You could make use of this like if ($fp = fopen($filename,'r')) since this is the same as if (($fp = fopen($filename,'r')) == TRUE) code after this line is executed when fopen() success to

Re: [PHP] assignment operator works for comparison??

2001-04-10 Thread Dan
You are right, thank you. > It looks to me like the value of an assignment is the value assigned, as in > Perl. But I don't know for sure, haven't come across this in the manual. > > Kirk > > > > > if($shiny = 0){ > > > This does not compare anyting, it assigns 0 to $shiny > > > > yes i know, bu

RE: [PHP] assignment operator works for comparison??

2001-04-10 Thread Johnson, Kirk
L PROTECTED] > Subject: Re: [PHP] assignment operator works for comparison?? > > > > > > > > if($shiny = 0){ > > This does not compare anyting, it assigns 0 to $shiny > > yes i know, but shouldnt this operation return true? -- PHP General Mailing List (

Re: [PHP] assignment operator works for comparison??

2001-04-10 Thread Dan
> > > if($shiny = 0){ > This does not compare anyting, it assigns 0 to $shiny yes i know, but shouldnt this operation return true? > > > echo( $shiny ) // this will return 0 > That's normal, you just assign 0 to it ;) > > = assignment operator > == comparison operator > > py > > > At 01:53 PM

Re: [PHP] assignment operator works for comparison??

2001-04-10 Thread Pierre-Yves Lemaire
> if($shiny = 0){ This does not compare anyting, it assigns 0 to $shiny > echo( $shiny ) // this will return 0 That's normal, you just assign 0 to it ;) = assignment operator == comparison operator py At 01:53 PM 4/10/01 -0700, you wrote: >This confused me for awhile, because the single eq

[PHP] assignment operator works for comparison??

2001-04-10 Thread Dan
This confused me for awhile, because the single equal sign seemed to work for comparison, but created inexplicable errors in my programs. It seems strange to me that a successful variable value assignment does not return true. example: --Dan -- PHP General Mailing List (http://www.php.net