diff --git a/phpdotnet/phd/Index.php b/phpdotnet/phd/Index.php
index 2f0d5d3e..9ecbe050 100644
--- a/phpdotnet/phd/Index.php
+++ b/phpdotnet/phd/Index.php
@@ -103,6 +103,7 @@ class Index extends Format
private $commit = array();
private $POST_REPLACEMENT_INDEXES = array();
private $POST_REPLACEMENT_VALUES = array();
+ private int $exampleCounter = 0;
public function __construct(IndexRepository $indexRepository) {
$this->indexRepository = $indexRepository;
@@ -377,16 +378,14 @@ public function format_short_desc($open, $name, $attrs, $props) {
}
public function format_example($open, $name, $attrs, $props) {
- static $n = 0;
-
if ($open) {
- ++$n;
+ ++$this->exampleCounter;
if(isset($attrs[Reader::XMLNS_XML]["id"])) {
$id = $attrs[Reader::XMLNS_XML]["id"];
}
else {
- $id = "example-" . $n;
+ $id = "example-" . $this->exampleCounter;
}
$this->storeInfo($name, $id, $this->currentchunk, false);
diff --git a/phpdotnet/phd/Package/Generic/XHTML.php b/phpdotnet/phd/Package/Generic/XHTML.php
index 7e6e837a..b16558c6 100644
--- a/phpdotnet/phd/Package/Generic/XHTML.php
+++ b/phpdotnet/phd/Package/Generic/XHTML.php
@@ -528,6 +528,8 @@ abstract class Package_Generic_XHTML extends Format_Abstract_XHTML {
protected $isSectionChunk = array();
protected $params = array();
+ protected int $exampleCounter = 0;
+
public function __construct() {
parent::__construct();
$this->registerPIHandlers($this->pihandlers);
@@ -1735,13 +1737,12 @@ public function format_note_title($open, $name, $attrs)
return '
';
}
public function format_example($open, $name, $attrs, $props) {
- static $n = 0;
if ($open) {
- ++$n;
+ ++$this->exampleCounter;
if (isset($props["id"])) {
return '
Example #1 - 1. example without an xml:id
+Example #2 - 2. example without an xml:id
+Example #3 - 3. example with an xml:id
+Example #4 - 4. example without an xml:id
+Example #5 - 5. example without an xml:id
+Example #1 - 1. example without an xml:id
+Example #2 - 2. example without an xml:id
+Example #3 - 3. example with an xml:id
+Example #4 - 4. example without an xml:id
+Example #5 - 5. example without an xml:id
+Example #1 - 1. example without an xml:id
+Example #2 - 2. example without an xml:id
+Example #3 - 3. example with an xml:id
+Example #4 - 4. example without an xml:id
+Example #5 - 5. example without an xml:id
+