attr() public method

Alias for getAttribute and setAttribute methods.
public attr ( string $name, string $value = null ) : string | null | Element
$name string The attribute name
$value string The attribute value or null if the attribute does not exist
return string | null | Element
コード例 #1
0
ファイル: ElementTest.php プロジェクト: nik4152/DiDOM
 public function testAttrGet()
 {
     $domElement = $this->createDomElement('input');
     $domElement->setAttribute("value", "test");
     $element = new Element($domElement);
     $this->assertEquals("test", $element->attr("value"));
 }
コード例 #2
0
 public function testAttrGet()
 {
     $domElement = $this->createDomElement('input');
     $domElement->setAttribute('value', 'test');
     $element = new Element($domElement);
     $this->assertEquals('test', $element->attr('value'));
 }
コード例 #3
0
ファイル: ElementTest.php プロジェクト: imangazaliev/didom
 public function testAttrGet()
 {
     $element = new Element('input', null, ['name' => 'username']);
     $this->assertEquals('username', $element->attr('name'));
 }
コード例 #4
0
ファイル: ElementTest.php プロジェクト: ixtel/DiDOM
 public function testAttrGet()
 {
     $node = $this->createNode('input');
     $node->setAttribute('value', 'test');
     $element = new Element($node);
     $this->assertEquals('test', $element->attr('value'));
 }