note 75257 added to function.dom-domelement-setidattribute

From: Date: Sun, 20 May 2007 19:54:29 +0000
Subject: note 75257 added to function.dom-domelement-setidattribute
Groups: php.notes 
Request: Send a blank email to php-notes+get-126777@lists.php.net to get a copy of this message
The second parameter doesn't exactly do, what you would expect. So use the method with care. If it is TRUE the method works like a switch. If it is FALSE the method turns ID setting off. A unit test demonstrates the exact behaviour: public function testSetIdAttribute() { $this->assertNull($this->dom->getElementById('testChild')); $this->child->setIdAttribute('id', TRUE); $this->assertType('DOMElement', $this->dom->getElementById('testChild')); $this->assertNotNull($this->dom->getElementById('testChild')); // TRUE switches between on and off, while false turns it off. $this->child->setIdAttribute('id', TRUE); $this->assertNull($this->dom->getElementById('testChild')); $this->child->setIdAttribute('id', TRUE); $this->assertNotNull($this->dom->getElementById('testChild')); $this->child->setIdAttribute('id', TRUE); $this->assertNull($this->dom->getElementById('testChild')); $this->child->setIdAttribute('id', TRUE); $this->assertNotNull($this->dom->getElementById('testChild')); // FALSE turns off and not on any more. $this->child->setIdAttribute('id', FALSE); $this->assertNull($this->dom->getElementById('testChild')); $this->child->setIdAttribute('id', FALSE); $this->assertNull($this->dom->getElementById('testChild')); $this->child->setIdAttribute('id', FALSE); $this->assertNull($this->dom->getElementById('testChild')); } ---- Server IP: 217.160.72.57 Probable Submitter: 85.182.160.82 ---- Manual Page -- http://www.php.net/manual/en/function.dom-domelement-setidattribute.php Edit -- https://master.php.net/note/edit/75257 Del: integrated -- https://master.php.net/note/delete/75257/integrated Del: useless -- https://master.php.net/note/delete/75257/useless Del: bad code -- https://master.php.net/note/delete/75257/bad+code Del: spam -- https://master.php.net/note/delete/75257/spam Del: non-english -- https://master.php.net/note/delete/75257/non-english Del: in docs -- https://master.php.net/note/delete/75257/in+docs Del: other reasons-- https://master.php.net/note/delete/75257 Reject -- https://master.php.net/note/reject/75257 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#126777) next »