How to get PHP to manipulate HTML code (copy/paste) before sending to the browser.
I want to use PHP to get html code form inside h1 and paste it in h2. On server. Before page is send over to the browser.
e.g ;
<h1> Some HTML CODE </h1>
<h2> <!-- EMPTY --> </h2>
<?php
// $var1 = HTML CODE from inside of h1
// Paste in $var1 inside h2
// Display The Page
?>
Edit: manipulating DOM before outputting through browser:
This is just an example. Read up on DOMDocument‘s documentation.
Previous answer: You can’t. PHP runs on the server side and javascript (thereby jQuery) on the client side. PHP doesn’t know how to handle anything happening in the browser after the page has loaded.