PHP Problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

PHP Problem

I created a new web code to use my newly learned PHP skills, and I was testing something out: <?php for($a = 1; $a <= 100; $a++){ echo("<p>Jeff</p>"); } ?> This resulted in the following: Jeff );}? The last line I am not sure if it printed exactly that, but it is usually below the echo line. •I have tried doing the echo with no parentheses But when I ran it with the PHP code, it printed Jeff 100 times(like it is supposed to), what is the problem?

23rd Mar 2018, 7:41 PM
Norberttony
Norberttony - avatar
2 Answers
+ 1
i guess your page extension is ".html" (f.e. mypage.html) if that is the case, change it to ".php" (f.e. mypage.php) and you shouldn't see the additional );}? charachters. that should be a security feature of servers. https://stackoverflow.com/questions/16995177/when-would-i-want-to-use-html-vs-php-as-a-file-extension
23rd Mar 2018, 8:18 PM
seamiki
seamiki - avatar
0
echo doesn’t use parentheses, most of the time, there are exceptions. If you want to use them use print() instead of echo.
23rd Mar 2018, 11:12 PM
C0D4
C0D4 - avatar