Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Non Breakable Spaces

Space is one of the base ASCII characters. They are often used to separate words, and are forbidden from being used in names.

PHP supports Unicode characters, and some of the characters are called: non breaking spaces. They behave like a space, by displaying a blank area. Yet, they are recognized internally as a non-space, and can be used in a name.

Non-breakable spaces are useful for tests, as they make the testing name more readable. They are also quite rare, and confusing for newcomers.

Unbreakable space is \u{00A0} as a PHP escape sequence, or \xc2\xa0 as ASCII characters; it is the HTML escape sequence  .

<?php

    // This is a space, PHP doesn't compile this code
    const A B = 1;

    // This is a non breakabe space, it compile and is not visibly different from the line above
    const A B = 1;
    echo A B;

?>

Documentation

See Also