public function read($input) { $xfer = 0; $fname = null; $ftype = 0; $fid = 0; $xfer += $input->readStructBegin($fname); while (true) { $xfer += $input->readFieldBegin($fname, $ftype, $fid); if ($ftype == TType::STOP) { break; } switch ($fid) { case 1: if ($ftype == TType::STRING) { $xfer += $input->readString($this->name); } else { $xfer += $input->skip($ftype); } break; case 2: if ($ftype == TType::I32) { $xfer += $input->readI32($this->num_children); } else { $xfer += $input->skip($ftype); } break; case 3: if ($ftype == TType::LST) { $this->counters = array(); $_size0 = 0; $_etype3 = 0; $xfer += $input->readListBegin($_etype3, $_size0); for ($_i4 = 0; $_i4 < $_size0; ++$_i4) { $elem5 = null; $elem5 = new \TCounter(); $xfer += $elem5->read($input); $this->counters[] = $elem5; } $xfer += $input->readListEnd(); } else { $xfer += $input->skip($ftype); } break; case 4: if ($ftype == TType::I64) { $xfer += $input->readI64($this->metadata); } else { $xfer += $input->skip($ftype); } break; case 5: if ($ftype == TType::BOOL) { $xfer += $input->readBool($this->indent); } else { $xfer += $input->skip($ftype); } break; case 6: if ($ftype == TType::MAP) { $this->info_strings = array(); $_size6 = 0; $_ktype7 = 0; $_vtype8 = 0; $xfer += $input->readMapBegin($_ktype7, $_vtype8, $_size6); for ($_i10 = 0; $_i10 < $_size6; ++$_i10) { $key11 = ''; $val12 = ''; $xfer += $input->readString($key11); $xfer += $input->readString($val12); $this->info_strings[$key11] = $val12; } $xfer += $input->readMapEnd(); } else { $xfer += $input->skip($ftype); } break; default: $xfer += $input->skip($ftype); break; } $xfer += $input->readFieldEnd(); } $xfer += $input->readStructEnd(); return $xfer; }
<?php require_once '../../Tephlon.php'; $c = new TCounter('myCtr'); $c->inc(); echo "You are the visitor number: " . $c->getCtr();
<html> <head> <title>TCounterTest</title> </head> <body> <?php /** * Please view this page from your browser. */ if (isset($_REQUEST['inc'])) { require_once '../Tephlon.php'; $c = new TCounter('ctrTest'); $c->inc(); echo $c->getCtr(); die; } echo "<h1>Atomic counter demo. No same numbers should appear.</h1>"; $url = $_SERVER['PHP_SELF'] . "?inc=1"; for ($i = 0; $i < 20; $i++) { echo '<iframe style="width:4em; height:4em; overflow:hidden;" src="' . $url . '"></iframe> '; } ?> </body>