Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP node not passing by reference
    primarykey
    data
    text
    <p>I have a bunch of dom manipulation functions within a class. One of those functions assigns unique ids to specific nodes.</p> <pre><code>$resource_info_node-&gt;setAttribute('id', 'resource_'.$this-&gt;ids); $details['id'] = 'resource_'.$this-&gt;ids; $details['node'] = $resource_info_node; $this-&gt;resource_nodes['resource_'.$this-&gt;ids] = $details; $this-&gt;ids += 1; </code></pre> <p>later I want to look up and modify those nodes. I have tried :</p> <pre><code>$current_node = $this-&gt;resource_nodes[$id]['node']; </code></pre> <p>When I print_r() I find that this node is a duplicate of the original node. It has the original node's attributes but is not a part of the DOM tree. I get the same results with :</p> <pre><code>$this-&gt;content-&gt;getElementById($id); </code></pre> <p>I suppose I based this whole thing on storing node references in an array. I thought that was a fine thing to do. Even if not, after that using getElementByID() should have returned the node within the dom.</p> <p>I thought that, in PHP all objects were passed by reference. Including DOM nodes. Any ideas on how I can test what is actually going on.</p> <p><strong>EDIT :</strong> </p> <p>Well I used :</p> <pre><code>$this-&gt;xpath-&gt;query('//*[@id]'); </code></pre> <p>That returned the right number of items with ids. The node is just not in the DOM tree when I edit it.</p> <p>and </p> <pre><code>$current_node = &amp;$this-&gt;resource_nodes[$id]['node']; </code></pre> <p>Using the reference syntax had no affect.</p> <p>The strangest part is that get elementById() is not returning a node in the dom. It has all the right attributes except no parentNode.</p> <p><strong>FIX - not answer :</strong> </p> <p>I just used xpath instead of my reference or getElementById().</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload