Print string in php
I am trying to print the following string in php
But it only prints
RQC7. If I remove the character
<, then I get the complete string. I do not understand why this is happening. I googled but could not find any answer.
I had to use an image because I could not print the total string in stack overflow either.
Actually this is part of a shared secret, which Client codes will access with
$obj->getSharedSecret(); I was just testing the output of the function with
var_dump(). If var_dump cannot print the total string, then this wont work to validate input, right?
You are, presumably, looking at the output in a web browser.
By default PHP will include a
Content-Type: text/htmlresponse header, so the browser will try to interpret the result as if it were HTML.
<means "Start of tag".
If you want to include
<as data, you need to use a character reference such as
htmlspecialcharsfunction to convert your string of text to a string of HTML.
<?php echo htmlspecialchars('RQC7<lxC; etc etc'); ?>
It because "<" is tag start, its actually printing string you want but you don't see it in your html. You need to take a look to source or use htmlentities or htmlspecialchars functions. Or if you prefer use var_dump for this kind of printing install xdebug (which will transform string into correct string representation)
you can use this