skip to Main Content

I have used one if condition and i’m using opencart platform

code is working fine in my local but not in the server

<? if ($a == '1') : ?>
   // if something
<? else: ?>
   // else something
<? endif; ?>

this code giving me an error in my server

i’m using php version 7.2 in both my local and server

2

Answers


  1. Make sure your code to be like this

    <?php if ($a == '1') : ?>
    // if something
    <?php else: ?>
    // else something
    <?php endif; ?>
    
    Login or Signup to reply.
  2. short tags are deprecated. short tags depend on an INI directive and as such are non-portable.

    If you enable short tags on server then you will not see error.

    It is recommended to use if else statemens without short tags.

    for more detail about short tags https://wiki.php.net/rfc/deprecate_php_short_tags

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search