<?php
/**
* HTML Document Wrapper for Experimentation
*
* This script wraps an existing HTML document to allow for
* experimentation with modifications before outputting to the browser.
* It focuses on basic wrapping and doesn't include complex feature sets.
*/
/**
* Wraps the HTML content within a <div id="experiment-container">.
* @param string $html The original HTML content.
* @return string The wrapped HTML.
*/
function wrapHtml($html) {
$wrappedHtml = '<!DOCTYPE html>' . PHP_EOL; //Ensure proper doctype
$wrappedHtml .= '<html lang="en">' . PHP_EOL;
$wrappedHtml .= '<head>' . PHP_EOL;
$wrappedHtml .= '<title>Experiment</title>' . PHP_EOL;
$wrappedHtml .= '<style>' . PHP_EOL;
$wrappedHtml .= ' #experiment-container { border: 1px solid #ccc; padding: 10px; margin: 10px; }' . PHP_EOL; //Basic styling for the container
$wrappedHtml .= '</style>' . PHP_EOL;
$wrappedHtml .= '</head>' . PHP_EOL;
$wrappedHtml .= '<body>' . PHP_EOL;
$wrappedHtml .= '<div id="experiment-container">' . PHP_EOL;
$wrappedHtml .= $html . PHP_EOL; // Insert the original HTML content
$wrappedHtml .= '</div>' . PHP_EOL;
$wrappedHtml .= '</body>' . PHP_EOL;
$wrappedHtml .= '</html>' . PHP_EOL;
return $wrappedHtml;
}
/**
* Example Usage (replace with your actual HTML loading)
*/
//Simulate loading HTML content from a file or database
$originalHtml = '<h1>Hello, World!</h1><p>This is a test.</p>';
// Wrap the HTML
$wrappedHtml = wrapHtml($originalHtml);
//Output the wrapped HTML. In a real application, you'd send this
//to the browser.
echo $wrappedHtml;
?>
Add your comment