引号不在php中工作

I am using php. This code does not work:

<?php
$str="<?palash";
print($str);

no output but it works as soon as I introduce a space between < and ?

<?php
$str="< ?palash";
print($str);// prints '< ?palash'

It doesn't print <b?palash because it has special characters in it.

If you want to print string with special characters then you should use htmlentities function: print htmlentities($str);

It does work, but your web browser interprets it as a broken HTML tag so it doesn't know what to do with your malformed HTML.

Try pressing Ctrl + U to view the source code.

Try this:

echo htmlentities("<?palash"); // produces &lt;?palash

you can also escape special characters by using a backslash \ before the special character ? that you want to escape

this will do what you're asking for

<?php
$str='<\?palash';
echo $str;
?>

cheers!