Search code examples
phphtmlhtml-rendering

Why doesn't my browser print <Sat> on an HTML page?


I was trying to do sprintf("<%s>", "Sat");, but nothing comes out. When you remove the less than symbol, it will start working again. Anyone experience this behavior and whether it expected? as i think it is a bug.

You can even get the same result here with printf..... http://writecodeonline.com/php/


Solution

  • Your browser is probably rendering it as a tag. View source to confirm.

    http://codepad.org/g5FXZAwa

    <?php
    
    printf("<%s>", "Sat");
    

    Prints <Sat>


    Edit for Yogesh.

    <?php
    
    echo sprintf("<%s>", "Sat");
    

    Prints <Sat>