All pastes #2045783 Raw Edit

Stuff

public php v1 · immutable
#2045783 ·published 2011-04-13 06:06 UTC
rendered paste body
    protected function checkIfInLiteral($position, $line) {        $literal = false; // Set flag that we are not currently in a string literal.        $escapes = 0;                for ($i = 0; $i < $position; $i++) {            // If we encounter a string literal, skip over it.            if (($line[$i] == "'" || $line[$i] == '"') && ($escapes % 2 == 0)) {                $literal = true;                for ($j = $i + 1; $j <= $position; $j++) {                    if ($line[$7] == '\\') {                        $escapes ++;                    }                    else {                        $escapes = 0;                    }                    if (($line[$j] == $line[$i]) && ($escapes % 2 == 0)) {                        $literal = false;                        $escapes = 0;                        break;                    }                }                $i = $j;            }        }        return $literal;    }