Replace DateTime with MyDateTime, to avoid possible confusion with the 5.2+ DateTime class

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@252996 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2008-02-15 23:14:12 +00:00
parent 123738b556
commit d81396423a

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<appendix xml:id="objaggregation.examples">
&reftitle.examples;
@ -16,9 +16,9 @@
<programlisting role="php">
<![CDATA[
<?php
class DateTime {
class MyDateTime {
function DateTime()
function MyDateTime()
{
// empty constructor
}
@ -35,7 +35,7 @@ class Report {
function Report()
{
$this->_dt = new DateTime();
$this->_dt = new MyDateTime();
// initialization code ...
}
@ -62,14 +62,14 @@ $rep = new Report();
<programlisting role="php">
<![CDATA[
<?php
class DateTime {
class MyDateTime {
// same as previous example
}
class DateTimePlus {
class MyDateTimePlus {
var $_format;
function DateTimePlus($format="Y-m-d H:i:s")
function MyDateTimePlus($format="Y-m-d H:i:s")
{
$this->_format = $format;
}
@ -81,7 +81,7 @@ class DateTimePlus {
}
class Report {
var $_dt; // we'll keep the reference to DateTime here
var $_dt; // we'll keep the reference to MyDateTime here
// more properties ...
function Report()
@ -89,7 +89,7 @@ class Report {
// do some initialization
}
function setDateTime(&$dt)
function setMyDateTime(&$dt)
{
$this->_dt =& $dt;
}
@ -104,17 +104,17 @@ class Report {
}
$rep = new Report();
$dt = new DateTime();
$dtp = new DateTimePlus("l, F j, Y (h:i:s a, T)");
$dt = new MyDateTime();
$dtp = new MyDateTimePlus("l, F j, Y (h:i:s a, T)");
// generate report with simple date for web display
$rep->setDateTime(&$dt);
$rep->setMyDateTime(&$dt);
echo $rep->generateReport();
// later on in the code ...
// generate report with fancy date
$rep->setDateTime(&$dtp);
$rep->setMyDateTime(&$dtp);
$output = $rep->generateReport();
// save $output in database
// ... etc ...