Skip to content

Instantly share code, notes, and snippets.

@clasen
Last active December 27, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clasen/7339362 to your computer and use it in GitHub Desktop.
Save clasen/7339362 to your computer and use it in GitHub Desktop.
<?php
require 'simple_html_dom.php';
$template_path = 'template/tagnu/';
$template_name = 'home.html';
$html = file_get_html($template_path . $template_name);
foreach ($html->find('link') AS $link) {
$url = parse_url($link->href);
if ( ! isset($url['scheme'])) { // NO http(s)
$link->href = $template_path . $link->href;
}
}
foreach ($html->find('script, img') AS $script) {
$url = parse_url($script->src);
if ( ! isset($url['scheme'])) { // NO http(s)
$script->src = $template_path . $script->src;
}
}
$txt = 'Hi! <showme> áéíóúñ';
$txt_escaped = filter_var($txt, FILTER_SANITIZE_SPECIAL_CHARS);
$html->find('p', 0)->innertext = $txt_escaped;
echo $html;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment