Blame | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?><!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>4.2. PHPlot Object Serialization</title><link rel="stylesheet" type="text/css" href="phplotdoc.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="PHPlot Reference Manual" /><link rel="up" href="advanced.html" title="Chapter 4. PHPlot Advanced Topics" /><link rel="prev" href="advanced.html" title="Chapter 4. PHPlot Advanced Topics" /><link rel="next" href="adv-truecolor.html" title="4.3. Truecolor Images" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.2. PHPlot Object Serialization</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="advanced.html">Prev</a> </td><th width="60%" align="center">Chapter 4. PHPlot Advanced Topics</th><td width="20%" align="right"> <a accesskey="n" href="adv-truecolor.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="adv-serialize"></a>4.2. PHPlot Object Serialization</h2></div></div></div><div class="abstract"><p class="title"><strong></strong></p><p>This section contains information about serializing and unserializinga PHPlot object.</p></div><p><span class="emphasis"><em>Serializing</em></span> a PHP variable, array, or objectwith the PHP function <code class="function">serialize()</code>generates a string representation of the value which can be stored ortransmitted.<span class="emphasis"><em>Unserialization</em></span> with the PHP function<code class="function">unserialize()</code> re-creates the variable, array, orobject from the string representation.</p><p>Starting with PHPlot-5.8.0, PHPlot objects can be serialized andunserialized, subject to these limitations:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>A PHPlot object can only be serialized until <a class="xref" href="DrawGraph.html" title="DrawGraph"><span class="refentrytitle">DrawGraph</span></a>is used.However, you can serialize the object, then call<code class="function">DrawGraph</code>, if you want both the serialization and theactual plot.</p></li><li class="listitem"><p>Serialization and unserialization will not work when an input file isspecified in the <a class="xref" href="PHPlot.html" title="PHPlot"><span class="refentrytitle">PHPlot</span></a> or<a class="xref" href="PHPlot-truecolor.html" title="PHPlot_truecolor"><span class="refentrytitle">PHPlot_truecolor</span></a> constructors.Consider using <a class="xref" href="SetBgImage.html" title="SetBgImage"><span class="refentrytitle">SetBgImage</span></a> instead.</p></li><li class="listitem"><p>You must serialize and unserialize with the exact same version of PHPlot.</p></li></ul></div><p></p><p>Here is an example of serializing a PHPlot object:</p><pre class="programlisting">require_once 'phplot.php';$plot = new PHPlot(800, 600);... // Configure the PHPlot object: Set plot type, data values, etc.// Do not use DrawGraph (yet)$str = serialize($plot);</pre><p></p><p>The corresponding unserialization looks like this:</p><pre class="programlisting">require_once 'phplot.php';$newplot = unserialize($str);// You can do additional plot setup here if desired.$newplot->DrawGraph(); // Draw it</pre><p></p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="advanced.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="advanced.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="adv-truecolor.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. PHPlot Advanced Topics </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4.3. Truecolor Images</td></tr></table></div></body></html>