Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
98 - 1
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
2
<!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>
3
This section contains information about serializing and unserializing
4
a PHPlot object.
5
  </p></div><p>
6
<span class="emphasis"><em>Serializing</em></span> a PHP variable, array, or object
7
with the PHP function <code class="function">serialize()</code>
8
generates a string representation of the value which can be stored or
9
transmitted.
10
<span class="emphasis"><em>Unserialization</em></span> with the PHP function
11
<code class="function">unserialize()</code> re-creates the variable, array, or
12
object from the string representation.
13
</p><p>
14
Starting with PHPlot-5.8.0, PHPlot objects can be serialized and
15
unserialized, subject to these limitations:
16
  </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
17
A PHPlot object can only be serialized until <a class="xref" href="DrawGraph.html" title="DrawGraph"><span class="refentrytitle">DrawGraph</span></a>
18
is used.
19
However, you can serialize the object, then call
20
<code class="function">DrawGraph</code>, if you want both the serialization and the
21
actual plot.
22
      </p></li><li class="listitem"><p>
23
Serialization and unserialization will not work when an input file is
24
specified in the <a class="xref" href="PHPlot.html" title="PHPlot"><span class="refentrytitle">PHPlot</span></a> or
25
<a class="xref" href="PHPlot-truecolor.html" title="PHPlot_truecolor"><span class="refentrytitle">PHPlot_truecolor</span></a> constructors.
26
Consider using <a class="xref" href="SetBgImage.html" title="SetBgImage"><span class="refentrytitle">SetBgImage</span></a> instead.
27
      </p></li><li class="listitem"><p>
28
You must serialize and unserialize with the exact same version of PHPlot.
29
      </p></li></ul></div><p>
30
</p><p>
31
Here is an example of serializing a PHPlot object:
32
</p><pre class="programlisting">require_once 'phplot.php';
33
$plot = new PHPlot(800, 600);
34
... // Configure the PHPlot object: Set plot type, data values, etc.
35
// Do not use DrawGraph (yet)
36
$str = serialize($plot);
37
</pre><p>
38
</p><p>
39
The corresponding unserialization looks like this:
40
</p><pre class="programlisting">require_once 'phplot.php';
41
$newplot = unserialize($str);
42
// You can do additional plot setup here if desired.
43
$newplot-&gt;DrawGraph(); // Draw it
44
</pre><p>
45
</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>