开发者

Help with a unexpected T_ELSE [closed]

开发者 https://www.devze.com 2022-12-20 21:45 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally ap开发
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally ap开发者_JAVA技巧plicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 9 years ago.

Now I have fixed the problem the T_ELSE parse error is not displaying anymore, But then how can I direct the code to display the if or the else?

Well users are going to come from either page1.php or page2.php

url coming from page1.php
cart.php?ids=1

url coming from page2.php
cart.php?idc=1

for instance if the url is coming from page1.php then cart is going to receive it like

$ids= isset($_GET['ids'])?(int) $_GET['ids']:null;

$idc= isset($_GET['idc'])?(int) $_GET['idc']:null;

if ($ids) { 
display something
} 
elseif($idc) {
display something different
}
else 
{ 

display nothing has passed 
}

Those are the conditions I have right but it is not working properly since it will display the else message "display nothing has passed". Again it will display the else statement even if I come from page1.php or page2.php. I guess the conditions are not well set up or it is passing empty. How can I set up the conditions so it can display either $ids statement or the elseif $idc.


This should work:

if (true) {
    for (blabla) {
        if (false) {
            // do something
        }// end of if statement inside the for loop

    } //end of for loop.

} // end of if statement 
else { // line 379
    // do something else

}// end of else statement


I assume that 'blabla' isn't actually in your code but there is, in fact, something meaningful there.

Remember to test for something with your if statement.

if($some_condition) {
  for(blabla) {
    if($another_condition) {
    } // end of if statement inside the for loop
  }   // end of for loop.
}     // end of if statement 
else{ // line 379

}// end of else statement


An else statement must immediately follow an if block, and will be associated with the if block that it follows. There cannot even be an extra } between the if block and the else.

You will get that error if you have anything other than whitespace or commetns between the } that closes the if and the else.

Can you show us exactly what that part of the file contains?


end of if statement should be commented out like so.

    if {
  for (blabla) {
    if {

    }// end of if statement inside the for loop

  } //end of for loop.

} // end of if statement 
else{ // line 379


}// end of else statement
0

精彩评论

暂无评论...
验证码 换一张
取 消