0

I'm trying to allow JS to execute inside PHP's output buffering.

I have tried declaring ob_start and then referencing the javascript, then getting the contents

<?php
ob_start(); ?>
<script language="Javascript" src="https://www.ip2phrase.com/j?template=.   <ISP>"></script>
<?php
$visitorISPW = ob_get_clean();

I was hoping to get the result of the JS src, which is a document.write.

Instead I get the full results of the script. The end result of the script is just javascript executing again from the source URL.

I would prefer the JS to execute, and then grab the result in PHP.

Best Dev Tutorials
  • 452
  • 2
  • 6
  • 22
  • This question is not a duplicate, clearly what I'm trying to do is possible. https://sebastiandedeyne.com/server-side-rendering-javascript-from-php/ – Best Dev Tutorials Jun 07 '19 at 17:32
  • 1
    What you're trying to do is *possible*, but doing it that way is fairly absurd. You'll be better off just using `file_get_contents('https://www.ip2phrase.com/j?template=%3CISP%3E')` and parsing the response. – ceejayoz Jun 07 '19 at 18:56
  • @ceejayoz Perfect thank you! – Best Dev Tutorials Jun 07 '19 at 19:12

0 Answers0