Answer the question
In order to leave comments, you need to log in
PhpStorm how to prevent adding slashes when inserting code into a string?
Hello. I have such a problem. If I take this code:
<div class="board-article__tags-bar tags-bar">
<div class="tags-wrap">
<?php
foreach ($item_tags as $tag) {
echo '<a href="/' . $material_alias . '?tag=' . $tag->name . '" class="tag label label-success">' . $tag->name . '</a>';
}
?>
</div>
</div>
$result = ''
$result = '<div class="board-article__tags-bar tags-bar">
<div class="tags-wrap">
<?php
foreach ($item_tags as $tag) {
echo \'<a href="/\' . $material_alias . \'?tag=\' . $tag->name . \'" class="tag label label-success">\' . $tag->name . \'</a>\';
}
?>
</div>
</div>';
Answer the question
In order to leave comments, you need to log in
ctrl+alt+shift+v or Edit -> Paste simple
Can be reassigned in Past Simple settings to ctrl + v.
It is he who escapes quotes so that the syntax does not break and everything works for you. If they are removed, then the first unescaped quote will end the line, and there will be a syntax error further.
Even the Toaster editor highlights double quotes correctly, and look what happens after the first unescaped one:
$result = '<div class="board-article__tags-bar tags-bar">
<div class="tags-wrap">
<?php
foreach ($item_tags as $tag) {
echo '<a href="/' . $material_alias . '?tag=' . $tag->name . '" class="tag label label-success">' . $tag->name . '</a>';
}
?>
</div>
</div>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question