DiDom\Element::attr PHP Method

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
    public function attr($name, $value = null)
    {
        if ($value === null) {
            return $this->getAttribute($name);
        }
        return $this->setAttribute($name, $value);
    }

Usage Example

示例#1
0
 public function testAttrGet()
 {
     $domElement = $this->createDomElement('input');
     $domElement->setAttribute("value", "test");
     $element = new Element($domElement);
     $this->assertEquals("test", $element->attr("value"));
 }
All Usage Examples Of DiDom\Element::attr