Shines this error Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or '; reviewed all signs seems in place, what's wrong?

<?php
 $i = 0;
 while($i < count($names)) {

 echo "<li>"
 echo "<div class = \"avatar\">;
 <img src=\"images/user.png\">;
</div>";
 echo "<h2>" . $names[$i] . "</h2>";

 echo "<p>Hello!</p>";
 echo "<div class = \"time\">09:15</div>";
echo"</li>";

 $i = $i + 1;
}
?>


the error says on line 6
March 25th 20 at 13:45
2 answers
March 25th 20 at 13:47
Solution
Throw away your book.
Start writing right away. So better admit it:

<?php $names=['Peter','Bob']; ?>

<?php if ($names): ?>
the <ul>
 <?php foreach ($names as $name): ?>
the <li>
 <div class = "avatar">
 <img src="images/user.png">
</div>
</li>
<h2><?=$name?></h2>
<p>hi!</p>
 <div class = "time">09:15</div>
 <?php endforeach; ?>
</ul>
<?php endif; ?>


This is called templates.
Well, you had to understand code that this is a beginner really - prince_Hilll commented on March 25th 20 at 13:50
You would have thrown all sorts endforeach, debajit sameness then - Ana.Dibbert commented on March 25th 20 at 13:53
If monkey gives advice, let them give the right advice. The link that the article is rubbish. Ranging from short tags in the examples to rules for filtering XSS. Except monkeys don't know what XSS should be filtered BEFORE storing in the database? There's still a lot of things - Rosario_McLaughlin commented on March 25th 20 at 13:56
@Rosario_McLaughlin, please don't write about what you don't have the slightest idea?

Ranging from short tags in examples
Where exactly did you see there is short tags? Tag - is an integral part of the language. Tag
Except monkeys don't know what XSS should be filtered BEFORE storing in the database?
NEVER BEFORE saved TO the database it is not necessary to "FILTER" the data. The data in the database are in the form in which they came from the user. Run the data through htmlspecialchars is done only when output to html. For different formats of the final documents may have their own requirements to display certain characters. And if the HTML needs to be converted to mnemonic characters used in HTML, it does not mean that it should be done for Word, PDF, or something else.

There's still a lot of things
I'm all ears. - Deanna_Bartell commented on March 25th 20 at 13:59
@Ana.Dibbert,
You would have thrown all sorts endforeach, debajit sameness then
perepeshite now an example with parentheses instead of the alternative syntax and you just semanales debajit. - Deanna_Bartell commented on March 25th 20 at 14:02
@Deanna_Bartellwhere I saw short tags? The article

NEVER BEFORE saved TO the database it is not necessary to "FILTER" the data. The data in the database are in the form in which they came from the user.

Uporotyh such a fun thing. I'm starting to understand why you with ten years of experience sucking his paw. I'm not even going to try to convince you - Rosario_McLaughlin commented on March 25th 20 at 14:05
@Rosario_McLaughlinand no, if you're hung "lucek", and consider themselves the smartest, come on, tell me what I'm wrong.

We develop a system where a Vitaliy Khomenko Tech Lead and Senior PHP Developer (and not PHP-monkey) decided that before insert in database you need to "Ko-Ko-Ko to remove bad characters". OK. We have implemented this wonderful code, most likely Vitali will write strip_tags or another library. All quotation marks like ' and " we will replace on mnemonics.

Then we will need to make the output in plain/text, for example any reports or logs. And here's the thing - in the text instead of an ampersand, quotation marks, and possibly more characters and less of mnemonics. Vitali will not be discouraged and will make the return haul data from mnemonics in symbols. What is already blatant stupidity for which Vitaly should be driven from the post of Tech Lead pissing rags.

Further, the business requirements have changed and we need to take from user (admin) HTML. But we "filtered" the data before the insert - so the whole system is built. In the best case, the database we have mnemonics in the worst works of some of strip_tags. And again, the system requires alterations.

And why? All from a total of flagrant misunderstanding and arrogance. - Deanna_Bartell commented on March 25th 20 at 14:08
In stripes, who cares? It is important not insignias, and the result.

All from a total of flagrant misunderstanding and arrogance.

@Deanna_Bartell, That's it, then totally agree: uporotyh and misunderstanding is the root of all problems. - Rosario_McLaughlin commented on March 25th 20 at 14:11
@Rosario_McLaughlin, clear, merged. - Deanna_Bartell commented on March 25th 20 at 14:14
@Deanna_Bartell, in the normal IDE I poke in the bracket and will see the beginning/end of block - Ana.Dibbert commented on March 25th 20 at 14:17
@Ana.Dibbert, perhaps the developers of many frameworks idiots that used to templates alternate syntax.. your right. I wrote them both. When the alternative syntax I code more understandable. - Deanna_Bartell commented on March 25th 20 at 14:20
March 25th 20 at 13:49
Solution
<?php
 $i = 0;
 while($i < count($names)) {

 echo "<li>"; //wasn't Here ;
 echo "<div class = \"avatar\">
 <img src=\"images/user.png\">
</div>";
 echo "<h2>" . $names[$i] . "</h2>";

 echo "<p>Hello!</p>";
 echo "<div class = \"time\">09:15</div>";
echo"</li>";

 $i = $i + 1;
 }

Find more questions by tags PHP