This question already has answers here:
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
Closed 4 years ago.
I know that in this code:
echo '<button style="width:100%;"class="uk-button" data-uk-modal="{target:#my-id'}">Kurstermine anzeigen</button>';
this: data-uk-modal="{target:#my-id'}" causes that any other code below won't run. But how can I fix it? I already tried fixing it by adding \ before the " but this doesn't change the behavior of the error.
<?php
echo <<<EOT
<button style="width:100%;"class="uk-button" data-uk-modal="{target:#my-id'}">Kurstermine anzeigen</button>
EOT;
Related
This question already has answers here:
How can I echo HTML in PHP?
(13 answers)
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
Closed 1 year ago.
else
{
echo <button onclick="window.location.href='des2.php';">lancer les des</button>;
}
How should I mark out the html code ?
This question already has answers here:
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
Closed 3 years ago.
my php code doesn't work inside a li tag.
I tried several things but it doesn't work.
echo '<li $page_title=="Cart" ? "class="nav-item active"" : "">';
I don't understand why it doesn't work, can someone help me with this code?
You can't execute php code inside of single quotes, and you can't do ternary operators inside of double quotes or single quotes. Store it in another variable and run it that way.
$class = ($page_title=='Cart') ? "class='nav-item active'" : '';
echo "<li $class>";
https://3v4l.org/uhQAi
This question already has answers here:
How can I combine two strings together in PHP?
(19 answers)
Closed 5 years ago.
I'm having some weird problem escaping " in an echo function.
echo "Site";
Any idea what I'm doing wrong?
You are doing it the javascript way for one. Concatenating in PHP works using . or ,.
Then you are using to many "
Try this line:
echo "Site";
This question already has answers here:
What is the difference between single-quoted and double-quoted strings in PHP?
(7 answers)
Closed 6 years ago.
first time asking here.
In php I need to insert a '$variable' as a string with the '$' sign into a $txt variable.
any ideas?
Thanks
Answer:
<?php $txt = '$variable' ?>
If you want know more how it works.
http://php.net/manual/en/language.types.string.php
This question already has answers here:
How can I combine two strings together in PHP?
(19 answers)
Closed 6 years ago.
Ya here is my code.
<?php print "<?php echo $this->lang('learn_cn')?>" ?>
It comes with blank nothing show.
<?php echo $this->lang('learn_cn')?>
What is the correct way to make this work. TY
You're already in the process of printing out HTML, so just escape that part like you did in the href:
<?php print "" . $this->lang('learn_cn') . "" ?>