Jyxo\Html::getBody PHP 메소드

getBody() 공개 정적인 메소드

Expects valid HTML source.
public static getBody ( string $html ) : string
$html string HTML source code
리턴 string
    public static function getBody(string $html) : string
    {
        // If the source code contains <body>, return this element's contents
        if (preg_match('~<body([^>]*)>(.*?)</body>~is', $html, $matches)) {
            $body = trim($matches[2]);
            // Converts <body> inline styles to a newly created <div> element
            if (preg_match('~style="[^"]+"~i', $matches[1], $style)) {
                $body = '<div ' . $style[0] . '>' . $body . '</div>';
            }
            return $body;
        }
        // Return everything otherwise
        return $html;
    }