Reputation: 119
How can I join '<' and 'div>'?
When I echo
<?php echo "<"."div>";?>
it returns an empty string.
Upvotes: 2
Views: 93
Reputation: 7716
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>');
Upvotes: 0
Reputation: 1011
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>"
Upvotes: 2
Reputation: 590
You can use htmlspecialchars for this.
<?php echo htmlspecialchars("<"."div>"); ?>
Upvotes: 0
Reputation: 2852
use:
htmlspecialchars("<a href='test'>Test</a>");
to display html tags in php
Upvotes: 0
Reputation: 19899
That's because you're echoing a HTML tag. View the source of the page.
Upvotes: 1