+ 2

Guys can you please tell me what's wring with this PHP script

Guys can you please tell me what's wring with this PHP script <?php $name = "<strong>Simar</strong"; for ($a = 0; $a < 6; $a++) { echo $name "<br />"; } ?>

9th Jul 2018, 5:10 AM
Simar
Simar - avatar
10 Respostas
+ 4
Hello, Simar ! The "for" loop starts the php script 6 times. <?php $name = "<strong>Simar</strong>"; for ($i = 0; $i < 6; $i++) { echo $name."<br />"; } /* output: 0.<strong>Simar</strong> 1.<strong>Simar</strong> 2.<strong>Simar</strong> 3.<strong>Simar</strong> 4.<strong>Simar</strong> 5.<strong>Simar</strong> */ ?> https://www.sololearn.com/learn/PHP/1826/?ref=app
9th Jul 2018, 5:16 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 3
Simar, Use the string concatenation operator. He looks like this "." For example: $name."<br/>";
9th Jul 2018, 5:25 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 3
Simar, $name = "<strong>Text</strong>";
9th Jul 2018, 5:59 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 2
yes, but why arent there line spaces in the output even if i have included "<br/>"
9th Jul 2018, 6:01 AM
Simar
Simar - avatar
+ 1
hey alexander, when i insert the code it comes up with Parse error: syntax error, unexpected '" "' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in ..\Playground\ PHP Parse error: syntax error, unexpected '" "' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in ..\Playground\
9th Jul 2018, 5:19 AM
Simar
Simar - avatar
+ 1
someone please help
9th Jul 2018, 5:58 AM
Simar
Simar - avatar
+ 1
Simar instead : $name = "<strong>Simar</strong"; use: echo "<strong>".$name."<strong>"; it is recommended. <?php $name = "Simar"; for ($i = 0; $i < 6; $i++) { echo "<strong>".$name."<strong>"."<br />"; }
9th Jul 2018, 6:26 AM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
you did not close the strong tag, its missing a >
9th Jul 2018, 7:57 AM
Dominique Abou Samah
Dominique Abou Samah - avatar
0
now the output is SimarSimarSimarSimarSimarSimar even tho i have included the "br/>"
9th Jul 2018, 5:29 AM
Simar
Simar - avatar
0
you are missing a "." between "$name" and '"<br>";' here is your code: <?php $name = "<strong>Simar</strong"; for ($a = 0; $a < 6; $a++) { echo $name[[missing .]] "<br />"; } ?> fix it by making it: <?php $name = "<strong>Simar</strong"; for ($a = 0; $a < 6; $a++) { echo $name."<br />"; } ?>
9th Jul 2018, 7:11 AM
Xpl0it
Xpl0it - avatar