0

I am getting script from some url like this

 $dom = new DomDocument();
 $url = "http://www.example.com";
 @$dom->loadHTMLFile($url); 
 foreach($dom->getElementsByTagName('*') as $element ){
 if ($element->tagName == 'script' && strpos($element->getAttribute('src'), '.js') == true)
{
    $files = $element->getAttribute('src');  
    $link[]=$files;


}


}
$domc = new DomDocument();
foreach($link as $ln ){
$html = file_get_contents($ln);
$script = $html;
print_r ($script);
}

Everything is working as expected, but if I have inside script append function I am missing everything inside quotes. For example this:

  $(".divc").append("<div></div>")

gives me in php output

 $(".divc").append("")

Why is this happening?

1
  • Because <div></div> are considered as html tags Commented Jan 3, 2017 at 21:44

1 Answer 1

1

Try viewing the source. Are the tags in there? If so, you either need to escape the HTML characters or you need to change the output format of your PHP document by adding this at the very top:

header("Content-Type: text/plain");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.