1. <?php
  2. /**
  3. * HTML Document Wrapper for Experimentation
  4. *
  5. * This script wraps an existing HTML document to allow for
  6. * experimentation with modifications before outputting to the browser.
  7. * It focuses on basic wrapping and doesn't include complex feature sets.
  8. */
  9. /**
  10. * Wraps the HTML content within a <div id="experiment-container">.
  11. * @param string $html The original HTML content.
  12. * @return string The wrapped HTML.
  13. */
  14. function wrapHtml($html) {
  15. $wrappedHtml = '<!DOCTYPE html>' . PHP_EOL; //Ensure proper doctype
  16. $wrappedHtml .= '<html lang="en">' . PHP_EOL;
  17. $wrappedHtml .= '<head>' . PHP_EOL;
  18. $wrappedHtml .= '<title>Experiment</title>' . PHP_EOL;
  19. $wrappedHtml .= '<style>' . PHP_EOL;
  20. $wrappedHtml .= ' #experiment-container { border: 1px solid #ccc; padding: 10px; margin: 10px; }' . PHP_EOL; //Basic styling for the container
  21. $wrappedHtml .= '</style>' . PHP_EOL;
  22. $wrappedHtml .= '</head>' . PHP_EOL;
  23. $wrappedHtml .= '<body>' . PHP_EOL;
  24. $wrappedHtml .= '<div id="experiment-container">' . PHP_EOL;
  25. $wrappedHtml .= $html . PHP_EOL; // Insert the original HTML content
  26. $wrappedHtml .= '</div>' . PHP_EOL;
  27. $wrappedHtml .= '</body>' . PHP_EOL;
  28. $wrappedHtml .= '</html>' . PHP_EOL;
  29. return $wrappedHtml;
  30. }
  31. /**
  32. * Example Usage (replace with your actual HTML loading)
  33. */
  34. //Simulate loading HTML content from a file or database
  35. $originalHtml = '<h1>Hello, World!</h1><p>This is a test.</p>';
  36. // Wrap the HTML
  37. $wrappedHtml = wrapHtml($originalHtml);
  38. //Output the wrapped HTML. In a real application, you'd send this
  39. //to the browser.
  40. echo $wrappedHtml;
  41. ?>

Add your comment