# PHP

To use this language, use the class "language-php".

## Comments

    // Single line comment
    /* Multi-line
    comment */
    # Shell-like comment

## Strings

    'foo \'bar\' baz'
    "foo \"bar\" baz"
    "a string # containing an hash"

## Variables

    $some_var = 5;
    $otherVar = "Some text";
    $null = null;
    $false = false;

## Functions

    $json = json_encode($my_object);
    $array1 = array("a" => "green", "red", "blue", "red");
    $array2 = array("b" => "green", "yellow", "red");
    $result = array_diff($array1, $array2);

## Constants

    define('MAXSIZE', 42);
    echo MAXSIZE;
    json_decode($json, false, 512, JSON_BIGINT_AS_STRING)

## PHP 5.3+ support

    namespace my\name;
    $c = new \my\name\MyClass;
    $arr = [1,2,3];
    trait ezcReflectionReturnInfo {
        function getReturnType() { /*1*/ }
        function getReturnDescription() { /*2*/ }
    }
    function gen_one_to_three() {
        for ($i = 1; $i <= 3; $i++) {
            // Note that $i is preserved between yields.
            yield $i;
        }
    }

## PHP embedded in HTML

    <div class="<?php echo $a ? 'foo' : 'bar'; ?>">
    <?php if($var < 42) {
        echo "Something";
    } else {
        echo "Something else";
    } ?>
    </div>

## Known failures

There are certain edge cases where Prism will fail. There are always such cases in every regex-based syntax highlighter. However, Prism dares to be open and honest about them. If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.

### Comment-like substrings

    "foo /* bar */ baz"; "foo // bar";

### Shell-like comments containing two quotes of the same type

    # Shell-like comment "with quotes" inside
    # Shell-like comment 'with quotes' inside

### A less-than sign and a greater-than sign on the same line

    if($a < $b && $b > $c) {}