[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Edlug Archive Mar 2004 ]

Re: [edlug] PHP Problem




Robert,


I'm using apache 2 and PHP 4.3.4  and I'm getting some unexpected
behaviour.  The following code:

	$v1 = "val 1";
	$v2 = "val 2";
	$v3 = "val 3";

$val = $v1 ? $v1 : $v2 ? $v2 : $v3;

echo $val;

yields "val 2", I would have expected it to yield "val 1", as does

$val = $v1 ? $v1 : ($v2 ? $v2 : $v3);


I think it's the same in perl. I haven't checked.


I always use brackets anyway otherwise it's ambiguous for the reader too.

Dick
-
----------------------------------------------------------------------
You can find the EdLUG mailing list FAQ list at:
http://www.edlug.org.uk/list_faq.html



This archive is kept by wibble@morpheux.org.DONTSPAMME
homepage