How can I join '<' and 'div>'?
When I echo
<?php echo "<"."div>";?>
it returns an empty string.
Because it is a HTML Tag. You cannot print it like this.
Still if you want to print it you can see @egig's suggestion. You can use echo "<"."div>"
That's because you're echoing a HTML tag. View the source of the page.
use:
htmlspecialchars("<a href='test'>Test</a>");
to display html tags in php
You can use htmlspecialchars for this.
<?php echo htmlspecialchars("<"."div>"); ?>
Your code is executed and the '<' is joined with the 'div>', however there is nothing to show as you are trying to output a partial HTML tag in PHP. You can do this by means of entity code:
< Less-than <
> Greater-than >
In your case it looks like:
echo "<"."div>";
Other means of doing this is using PHP to add these entity codes for you:
htmlentities — convert all applicable characters to HTML entities
In code:
echo htmlentities('<div>');
Make sure you use echo, or otherwise you would end up with an empty string again.
Other means:
htmlspecialchars — convert special characters to HTML entities
In code:
echo htmlspecialchars('<div>');