Welcome Guest, Not a member yet? Register   Sign In
form_radio problem
#1

[eluser]Kfrico[/eluser]
Code:
$abc = 'a';
   echo '狀態: ';
   echo form_radio('Status', 'a',if($abc == 'a')echo TRUE;);

Parse error: syntax error, unexpected T_IF in

WHY?
#2

[eluser]xwero[/eluser]
You can't add a control structure as a parameter. and using echo makes it even worse as it outputs the value.
#3

[eluser]Bogdan Tanase[/eluser]
right!

I think you could write it like this:

Code:
echo form_radio('Status','a',($abc=='a')?TRUE:FALSE);
#4

[eluser]Pascal Kriete[/eluser]
($abc == 'a') is already a boolean expression.
Code:
echo form_radio('Status','a', ($abc=='a') );
#5

[eluser]Kfrico[/eluser]
thanks
#6

[eluser]Bogdan Tanase[/eluser]
[quote author="inparo" date="1222976498"]($abc == 'a') is already a boolean expression.
[/quote]

True, but I wanted to exemplify the use of the ternary operator instead of if control structure




Theme © iAndrew 2016 - Forum software by © MyBB