<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title> To String </title> <link rel="stylesheet" href="book.css" type="text/css" /> <meta name="generator" content="DocBook XSL Stylesheets V1.69.1" /> <link rel="start" href="index.html" title="HTML_CSS Manual" /> <link rel="up" href="ch06.html" title="Chapter 6. Output" /> <link rel="prev" href="ch06s04.html" title="To File" /> <link rel="next" href="ch06s06.html" title="Display" /> <style type="text/css"> /*<![CDATA[*/ body { background-color: white; color: black; } :link { color: #0000FF } :visited { color: #840084 } :active { color: #0000FF } div.c2 {font-family: monospace;} h2.c1 {clear: both} /*]]>*/ </style> </head> <body> <table class="htmlcssHeader"> <tr> <td> <img src="img/pearsmall.gif" align="left" alt="PEAR logo" /> <h1> HTML_CSS : The Definitive Guide </h1> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center"> To String </th> </tr> <tr> <td width="20%" align="left"> <a accesskey="p" href="ch06s04.html">Prev</a> </td> <th width="60%" align="center"> Chapter 6. Output </th> <td width="20%" align="right"> <a accesskey="n" href="ch06s06.html">Next</a> </td> </tr> </table> </div><br /> <br /> </td> </tr> </table> <div class="sect1" lang="en" xml:lang="en"> <div class="titlepage"> <h2 class="title c1"> <a name="developers.output.string" id= "developers.output.string"></a>To String </h2> </div> <p> <code class="methodname">HTML_CSS::toString()</code> is analogous to <code class="methodname">HTML_CSS::toFile()</code> except that result is capture to a PHP variable rather than to a text/css file. </p> <div class="php c2"> <ol> <li class="li1"> <div class="de1"> <span class="kw2"><?php</span> </div> </li> <li class="li1"> <div class="de1"> <span class="kw1">require_once</span> <span class= "st0">'HTML/CSS.php'</span>; </div> </li> <li class="li1"> <div class="de1"> </div> </li> <li class="li1"> <div class="de1"> <span class="re0">$css</span> = <span class="kw2">new</span> HTML_CSS<span class="br0">(</span><span class="br0">)</span>; </div> </li> <li class="li1"> <div class="de1"> </div> </li> <li class="li1"> <div class="de1"> <span class="re0">$strcss</span> = <span class="st0">'</span> </div> </li> <li class="li1"> <div class="de1"> <span class="st0">ul, body {</span> </div> </li> <li class="li1"> <div class="de1"> <span class="st0"> padding: 1em 2em;</span> </div> </li> <li class="li1"> <div class="de1"> <span class="st0">}</span> </div> </li> <li class="li1"> <div class="de1"> <span class="st0">'</span>; </div> </li> <li class="li1"> <div class="de1"> <span class="re0">$css</span>-><span class= "me1">parseString</span><span class="br0">(</span><span class= "re0">$strcss</span><span class="br0">)</span>; </div> </li> <li class="li1"> <div class="de1"> <span class="re0">$css</span>-><span class= "me1">setGroupStyle</span><span class="br0">(</span><span class= "nu0">1</span>, <span class="st0">'color'</span>, <span class= "st0">'red'</span><span class="br0">)</span>; </div> </li> <li class="li1"> <div class="de1"> </div> </li> <li class="li1"> <div class="de1"> <span class="re0">$str</span> = <span class= "re0">$css</span>-><span class= "me1">toString</span><span class="br0">(</span><span class= "br0">)</span>; </div> </li> <li class="li1"> <div class="de1"> <span class="kw3">echo</span> <span class="re0">$str</span>; </div> </li> <li class="li1"> <div class="de1"> <span class="co1">// will display</span> </div> </li> <li class="li1"> <div class="de1"> <span class="co1">// ul, body { padding: 1em 2em; color: red; }</span> </div> </li> <li class="li1"> <div class="de1"> <span class="kw2">?></span> </div> </li> </ol> </div> </div> <table class="htmlcssFooter"> <tr> <td align="left"> HTML_CSS : The Definitive Guide </td> <td align="right"> v 1.1.3 : February 18, 2007 </td> </tr> </table> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"> <a accesskey="p" href="ch06s04.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="ch06.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="ch06s06.html">Next</a> </td> </tr> <tr> <td width="40%" align="left" valign="top"> To File </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> Display </td> </tr> </table> </div> </body> </html>