Return andrebaill result in browser

1

I have the following answer:

<<?php echo $valor->usu_id; ?>>

However, it is interpreted by the browser as TAG and not as a return. How do I return it without being tagged? In this example, I would return% with%

    
asked by anonymous 05.11.2017 / 18:29

1 answer

2

Use HTML entities, like this:

&lt;<?php echo $valor->usu_id; ?>&gt;

An example in pure HTML:

Vira tag: <br>

<foobar>

<hr>

É "visivel": <br>

&lt;foobar&gt;

List of HTML entities in the w3.org site: link

If the content comes from a variable in PHP (or bank) you can use htmlspecialchars like this:

<?php $foobar = '<foobar>'; ?>

<?php echo htmlspecialchars($foobar); ?>
  

Note:

     

The difference of htmlspecialchars and htmlentities is that htmlspecialchars only encodes characters that have some meaning for HTML, whereas htmlentities encodes everything that has the equivalent in "HTML entities" / em>

Note that the <xmp> tag may also have the same effect, however it is deprecated (though it still works):

<xmp><foobar></xmp>
    
05.11.2017 / 19:41