+ 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 />"; } ?>
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
+ 3
Simar,
Use the string concatenation operator. He looks like this "."
For example: $name."<br/>";
+ 3
Simar,
$name = "<strong>Text</strong>";
+ 2
yes, but why arent there line spaces in the output even if i have included "<br/>"
+ 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\
+ 1
someone please help
+ 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 />";
}
+ 1
you did not close the strong tag, its missing a >
0
now the output is
SimarSimarSimarSimarSimarSimar
even tho i have included the "br/>"
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 />";
}
?>