The problem is basically using a PHP code within a text in PHP. You set the text in double quotes and this tells PHP to interpret your content. What does that mean? That if there is a PHP variable inside string it will try to replace it with its respective value. You did:
echo "<img class='nav-user-photo' src='<?php echo $_SESSION['avatar'];?>'/>";
And $_SESSION is a PHP variable, so it tries to replace with its value. In this case, the value would be a array, which already complicates in replacing the value of a array within a string, but soon after you use ['avatar'], in order to inform the value of the array that you want. In this case, the syntax becomes invalid, PHP cannot correctly interpret and triggers the cited error. To do so, when you need to access a certain position of a array within a string, you will need to do this between keys ({}). In this way, you tell PHP that what is inside the keys must be analyzed together and thus PHP will understand that what you need is to access the key avatar of array $_SESSION.
The right thing would be:
echo "<img class='nav-user-photo' src='{$_SESSION['avatar']}'/>";
Note that the PHP code inside the string is unnecessary and will not work. Even if you did not get this wrong, your HTML would be wrong, because the internal PHP code would be sent as text. Either do the above solution using the keys, or you can use the concatenation operator:
echo "<img class='nav-user-photo' src='" . $_SESSION['avatar'] . "'/>";
You have a PHP code in a string in PHP? PHP Inception.
– Woss
PHP what? Inception?? @Andersoncarloswoss
– AlarockLee
It’s a php code on a php page. All my code is this
– AlarockLee
Still having the bug @Marceloboni. Same
– AlarockLee
the Inception was a joke referring to the film Inception, that people enter the dream dream of the dream... I hope you didn’t misunderstand and see if the answer was clear enough.
– Woss