PLZ: A handy PHP library for lazy programmers
  • Namespace
  • Class
  • Tree
  • Todo

Namespaces

  • amekusa
    • plz
  • PHP

Classes

  • alt
  • arr
  • constant
  • dom
  • fn
  • num
  • obj
  • op
  • path
  • str
  • sys
  • T
  • type
  • xml

Exceptions

  • ErrorException

Class dom

Document Object Model utilities

To get started, place the following line around top of your code.

use amekusa\plz\dom;

Direct known subclasses

amekusa\plz\xml

Abstract
Namespace: amekusa\plz
Located at dom.php

Methods summary

public static string
# attr( string $Name, mixed $Value, mixed $Default = null )

Returns a DOM attribute expression

Returns a DOM attribute expression

Parameters

$Name
Attribute name
$Value
Attribute value
$Default
(optional) Default value of the attribute

Returns

string
DOM attribute expression

Example

"class" attribute

$class = 'cols';
echo '<div' . dom::attr('class', $class) . '>';
<div class="cols">

Returns nothing if the value is empty

$class = ''; // Empty string
echo '<div' . dom::attr('class', $class) . '>';
<div>

Boolean attribute

echo '<input type="radio"' . dom::attr('checked', true) . '/>' . "\n";
echo '<input type="radio"' . dom::attr('checked', false) . '/>';
<input type="radio" checked="checked"/>
<input type="radio"/>

public static string
# attrs( array|object $Attrs )

Returns DOM attribute(s) expression

Returns DOM attribute(s) expression

Parameters

$Attrs
Associative array the structure of which is [Name => Value]

Returns

string
DOM attribute(s) expression

Example

Multiple attributes

$var = array (
  'name' => 'eula',
  'type' => 'checkbox',
  'value' => 'agreed'
);
echo '<input' . dom::attrs($var) . '/>';
<input name="eula" type="checkbox" value="agreed"/>

PLZ: A handy PHP library for lazy programmers API documentation generated by ApiGen