attr() публичный Метод

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
Результат string | null | Element
Пример #1
0
 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
 public function testAttrGet()
 {
     $element = new Element('input', null, ['name' => 'username']);
     $this->assertEquals('username', $element->attr('name'));
 }
Пример #4
0
 public function testAttrGet()
 {
     $node = $this->createNode('input');
     $node->setAttribute('value', 'test');
     $element = new Element($node);
     $this->assertEquals('test', $element->attr('value'));
 }