tags:

views:

58

answers:

2
var_dump('<a>')
// or
var_dump("<a>")
// or
var_dump("\x3Ca>")

// all result in
string(3) ""

What is going on? Only putting a space after the less-than sign works for me.

PHP Version 5.2.10-2ubuntu6.4

+8  A: 

The <a> is probably getting rendered as an empty tag in the browser - try viewing the page source

Josh
It is. Add htmlspecialchars() to get a printable version.
Savageman
Or render as plain text rather than HTML.
salathe
A: 

I believe var_dump takes an expression, not a string. So:

<?php

$a = "<a>";
var_dump($a); 

?>

Should work.

jonesy
No, var_dump() can also handle plain string.
Savageman