getMessage(), (int)$e->getCode()); } return $pdo; } /** * Append HTML to DOMDocument * * @param DOMNode $parent * @param String $source */ public static function appendHTML(DOMNode $parent, String $source) { $tmpDoc = new DOMDocument("1.0", "UTF-8"); $html = ""; $html .= $source; $html .= ""; $tmpDoc->loadHTML(''.$html); /** @var DOMNode $item */ foreach ($tmpDoc->childNodes as $item) if ($item->nodeType == XML_PI_NODE) $tmpDoc->removeChild($item); $tmpDoc->encoding = 'UTF-8'; /** @var DOMNode $node */ foreach($tmpDoc->getElementsByTagName('body')->item(0)->childNodes as $node) { $importedNode = $parent->ownerDocument->importNode($node, true); $parent->appendChild($importedNode); } } public static function deleteDir($dirPath) { if (! is_dir($dirPath)) { throw new InvalidArgumentException("$dirPath must be a directory"); } if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { $dirPath .= '/'; } $files = glob($dirPath . '*', GLOB_MARK); foreach ($files as $file) { if (is_dir($file)) { self::deleteDir($file); } else { unlink($file); } } rmdir($dirPath); } }