PEAR logo

HTML_CSS : The Definitive Guide

To String

HTML_CSS::toString() is analogous to HTML_CSS::toFile() except that result is capture to a PHP variable rather than to a text/css file.

  1. <?php
  2. require_once 'HTML/CSS.php';
  3.  
  4. $css = new HTML_CSS();
  5.  
  6. $strcss = '
  7. ul, body {
  8.  padding: 1em 2em;
  9. }
  10. ';
  11. $css->parseString($strcss);
  12. $css->setGroupStyle(1, 'color', 'red');
  13.  
  14. $str = $css->toString();
  15. echo $str;
  16. // will display
  17. // ul, body { padding: 1em 2em; color: red; }
  18. ?>
HTML_CSS : The Definitive Guide v 1.5.0 : January 15, 2008