<?~ $value ?> <?= htmlspecialchars($value, ENT_QUOTES) ?>. - , . , PHP- . <?= h($value) ?> , - , - .<?~ ?>, . , PHP7, , RFC.<a href="/things/<?= $thing['name'] ?>" onclick="alert('<?= $thing['name'] ?>');">
    <?= $thing['name'] ?>
</a>
<?php $thing = ['name' => 'Say "Hello")']; ?>
<a
    href="/things/<?= htmlspecialchars(urlencode($thing['name'])) ?>"
    onclick="alert(<?= htmlspecialchars(json_encode($thing['name']), ENT_QUOTES) ?>);"
>
    <?= htmlspecialchars($thing['name']) ?>
</a>
<?php
    $postData = ['contains_text' => 'Say "Hello")'];
    $filterUrl = '/my_route/?state=active';
    if ($postData['contains_text']) $filterUrl .= '&' . 'contains_text=' . urlencode($postData['contains_text']);
    $pageNumber = 1;
?>
<a
    href="<?= htmlspecialchars($filterUrl) ?>"
    onclick="alert(<?= htmlspecialchars(json_encode($postData['contains_text']), ENT_QUOTES) ?>);"
>
    <?= $pageNumber ?>
</a>
style script.1  HTML         ,    (  3 )
2  HTML + URL   href, action,    data-url
3  HTML + JS    on-event - onclick, onkeypress  ..
4  HTML + CSS   style
5  URL         -
6  JS           <script></script>
7  CSS          <style></style>
8  non-HTML          ,    .
<?~ ?> «php.ini» . , Shift, <?= ?> , . - htmlspecialchars(), . , <?php echo htmlspecialchars($str, ENT_QUOTES) ?>, <?= ?> <?php echo $str; ?>Source: https://habr.com/ru/post/304162/
All Articles