First, I would recommend using the identical operator in PHP to compare strings which in this case would be the !==
rather than just !=
or use the strcmp()
to that end.
Another thing to say is that the second assignment to the string value of the variable $function
is in trouble, you should not concatenate the string this way.
Another addendum would be to use an if ternary operator to realize such a condition imposed by you without the need to create a variable as well.
In this part you should use a .
to delimit a string from another, or to make the string as one.
$function = '<li>''<a href="Alt_Papel.php">'.Alterar papel - D.'</a>''</li>'; //isto é totalmente incorreto.
$function = '<li>'.'<a href="Alt_Papel.php">'.'Alterar papel - D'.'</a>'.'</li>'; //isto é correto, porém não necessário.
$function = '<li><a href="Alt_Papel.php">Alterar papel - D</a></li>'; //isto é ideal.
For example only, because there is also another incorrect part in your string.
Applying the recommendations I mentioned your code would look this way:
<nav id="menu">
<ul>
<li><a href="index.php">Minimo Nulo</a></li>
<li><a href="Fechamento.php">Divergência de campos </a></li>
<?php
echo ($nivel !== 'MM' || $nivel !== 'AAAA') ? '' : '<li><a href="Alt_Papel.php"> Alterar papel - D </a></li>';
?>
</ul>
</nav>
This post is falling into "low quality" due to the size of your content. Please make an example of your answer. Review
– Don't Panic