简体   繁体   中英

How add to a backspace character to a string literal?

I use \\b to generate backspace in PHP: But I think it doesn't work:

        if(isset($_GET['submit'])){
            $n = $_GET['n'];
            $c = $_GET['c'];
            $space = " "; $i=0; $j=0; $k=0;

            do{
                $space = $space." ";
                $i++;
            }while($i < $n);

            for($j=0; $j < $n ; $j++){
                echo $space;

                for($k=0; $k < $j*2 - 1; $k++){
                    echo $c;
                }
                echo $space."\b";
                echo "<br />";
            }
        }

If you want to delete last char in a string just do:

$space = substr($space,0,-1);     //> Reccomanded

or

substr($space,0,count($space)-1); //> Slower

or

substr_replace($space,'',-1);     //> Uglier

也许你的意思是: "\\x8"

Indeed, it's not on the list . You have to use the octal or hexadecimal notation.

In any case, the backspace character has little use outside a text console, not to mention HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM