I was writing the code:
<?PHP
$where='<something';
echo $where;
?>
but it doesn't echo anything until I change the string $where to '< something'(add a space after "<"), why?
It might compile < to the begining of some markup language.
Less than < and greater than > signs are html entities or reserved symbols to denote html tags. To display them you need to use entity name or entity number. In case of "less than" they are < and < respectively.
So change your code like this:
$where='<someting'; echo $where;
or better yet
$where='<someting'; echo htmlentities($where);
as correctly suggested by @Waleed Kahn.
echo htmlentities($where).In a browser, < introduces an HTML tag. If your string were $where = "<img" you'd probably end up with something like this:
Whenever you are outputting text, you should always either run htmlentities, htmlspecialchars or just str_replace("<","<",$where); to escape HTML from being processed (the last one will still allow &characters;)
It is because browsers treat the opening bracket, <, as an HTML tag. In the browser, right-click the page and select "View source".
If you have a terminal then you can use:
php -f file.php
That will output the raw content without parsing it.
If you want to see the code in your browser then you need to encode HTML characters using something like htmlentities():
$where = '<something';
echo htmlentities($where); // <something
"<something"instead?