-5
In the code, there are several conditions, according to the choices of the user. The system is simple, just checks whether or not the user can receive unemployment insurance. I’m following the chart:
My code is this:
<?php
$tx = 2;
/* Exibe o resultado caso a variável possua um valor diferente de null */
if ($tx !== null):
if($pedido == primeira):
if($meses >= 12 && $meses <= 23):
$parcela = "4";
elseif($meses > 23):
$parcela = "5";
elseif($pedido == segunda):
if($meses >= 9 && $meses <= 11):
$parcela = "3";
elseif($meses > 11 && $meses < 24):
$parcela = "4";
elseif($meses > 24):
$parcela = "5";
endif;
endif;
endif;
You’re making the mistake:
Parse error: syntax error, unexpected end of file in > C:\wamp\www\extudando.esy.es\teste.php on line 24
and there’s nothing on line 24
I also know that the syntax must be wrong (like it works, but it is gambiarra), but I could not think of a more "correct" way. How could I fix this? Or the only way would be IF IF IF ? And I can’t correct the error
Substitute
$meses => 12
for$meses >= 12
. This happens because=>
is used to assign a value to an Array index, so PHP accuses the error.– Valdeir Psr
endif
wave;
to close. It is advisable to review the syntax of the language whenever you have doubts.– Isac
After editing... Missing a variable in
&& <=23
, the correct is&& $variavel <=23
.– Valdeir Psr
$parcela =
also can not stay that way.– Valdeir Psr
I fixed that same Isac ! I completed, and corrected the order of =< .... but now gives the error:
– Flávia
Parse error: syntax error, Unexpected '<' in C: wamp www extudando.esy.es rh_seg-des.php on line 62
– Flávia
@Flavia The correct is
<=
and not=<
. I recommend reading http://php.net/manual/en/language.operators.comparison.php– Valdeir Psr
I corrected it, recreated it, yet there’s some error in the syntax, and I don’t know what I’m doing wrong
– Flávia
@Flavia there are two errors in her - new - code. 1) It is necessary to involve the words
primeira
andsegunda
by quotation marks or adding the$
and turn them into variables; 2) Missing aendif;
beforeelseif($pedido == segunda):
– Valdeir Psr