src/UI/HTML/Tag.php
public function setAttribute( $key, $value = NULL, $strict = TRUE )
	{
		if( empty( $key ) )																			//  no valid attribute key defined
			throw new InvalidArgumentException( 'Key must have content' );							//  throw exception
		$key	= strtolower( $key );
		if( array_key_exists( $key, $this->attributes ) && $strict )								//  attribute key already has a value
			throw new RuntimeException( 'Attribute "'.$key.'" is already set' );					//  throw exception
		if( !preg_match( '/^[a-z0-9:_-]+$/', $key ) )												//  key is invalid
			throw new InvalidArgumentException( 'Invalid attribute key "'.$key.'"' );				//  throw exception

		if( $value === NULL || $value === FALSE ){													//  no value available
			if( array_key_exists( $key, $this->attributes ) )										//  attribute exists
				unset( $this->attributes[$key] );													//  remove attribute
		}
		else
		{
//			if( is_string( $value ) || is_numeric( $value ) )										//  value is string or numeric
//				if( preg_match( '/[^\\\]"/', $value ) )												//  detect injection
//					throw new InvalidArgumentException( 'Invalid attribute value' );				//  throw exception
			$this->attributes[$key]	= $value;														//  set attribute
		}
	}
public function setAttribute( $key, $value = NULL, $strict = TRUE )
	{
		if( empty( $key ) )																			//  no valid attribute key defined
			throw new InvalidArgumentException( 'Key must have content' );							//  throw exception
		$key	= strtolower( $key );
		if( array_key_exists( $key, $this->attributes ) && $strict )								//  attribute key already has a value
			throw new RuntimeException( 'Attribute "'.$key.'" is already set' );					//  throw exception
		if( !preg_match( '/^[a-z0-9:_-]+$/', $key ) )												//  key is invalid
			throw new InvalidArgumentException( 'Invalid attribute key "'.$key.'"' );				//  throw exception

		if( $value === NULL || $value === FALSE ){													//  no value available
			if( array_key_exists( $key, $this->attributes ) )										//  attribute exists
				unset( $this->attributes[$key] );													//  remove attribute
		}
		else
		{
//			if( is_string( $value ) || is_numeric( $value ) )										//  value is string or numeric
//				if( preg_match( '/[^\\\]"/', $value ) )												//  detect injection
//					throw new InvalidArgumentException( 'Invalid attribute value' );				//  throw exception
			$this->attributes[$key]	= $value;														//  set attribute
		}
	}
public function setAttribute ( $ key , $ value = NULL , $ strict = TRUE ) { if ( empty ( $ key ) ) //  no valid attribute key defined throw new InvalidArgumentException ( 'Key must have content' ) ; //  throw exception $ key = strtolower ( $ key ) ; if ( array_key_exists ( $ key , $ this -> attributes ) && $ strict ) //  attribute key already has a value throw new RuntimeException ( 'Attribute "' . $ key . '" is already set' ) ; //  throw exception if ( ! preg_match ( '/^[a-z0-9:_-]+$/' , $ key ) ) //  key is invalid throw new InvalidArgumentException ( 'Invalid attribute key "' . $ key . '"' ) ; //  throw exception if ( $ value === NULL || $ value === FALSE ) { //  no value available if ( array_key_exists ( $ key , $ this -> attributes ) ) //  attribute exists unset ( $ this -> attributes [ $ key ] ) ; //  remove attribute } else { //			if( is_string( $value ) || is_numeric( $value ) )										//  value is string or numeric //				if( preg_match( '/[^\\\]"/', $value ) )												//  detect injection //					throw new InvalidArgumentException( 'Invalid attribute value' );				//  throw exception $ this -> attributes [ $ key ] = $ value ; //  set attribute } }
Sets attribute of tag.
@access		public
@param		string		$key			Key of attribute
@param		string		$value			Value of attribute
@param		boolean		$strict			Flag: deny to override attribute
@return		void
Sets attribute of tag .