is being ignored because as stated in documentation first parameter is format
which should be printed and rest of parameters are values which this format can use, for instance:
$num = 2.12;
printf("formatted value = %.1f", $num);
// ^^^^^^^^^^^^^^^^^^^^^^ ^^^^
// | |
// format |
// value which can be put in format in place of `%X` where `X` represents type
will print formatted value = 2.1
because in format %.1f
you decided to print only one digit after dot in floating point number.
To make format use string argument you need to use %s
placeholder like in case of print("hello %s world","beautiful")
which would put beautiful
in place of %s
and print hello beautiful world
.
Now lets back to your code. In printf($variable, "
");
$variable
represents format, and it most probably doesn't have any %s
for string in it which would let you put use "
"
argument in this format. This means that "
"
will be ignored (not used in format) so will not be printed.
Code like this
printf("Hello
");
or
printf($variable);
printf("
");
doesn't have this problem because it explicitly use
in format which should be printed.
So it seems that you may either want to use
printf("%s
", $value)
which seems like overkill because you can simply concatenate strings using .
operator and print them like
print($value."
")
or
echo $value."
";
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…