-
Notifications
You must be signed in to change notification settings - Fork 20
Creator
Thomas Weinert edited this page Aug 16, 2014
·
17 revisions
(FluentDOM 5.1)
The FluentDOM\Nodes\Creator is a functor, a class usable like a function. In PHP you implement the magic method __invoke to support this. It allows you to have a function with a state/configuration.
You can use the FluentDOM::create() method to get a new instance and assign it to a variable.
The first argument of the function is the node name. The returned object can be cast to string.
$_ = FluentDOM::create();
echo $_('ul');<?xml version="1.0" encoding="UTF-8"?>
<ul/>Other arguments can set attributes (arrays or attribute nodes) and add text nodes (string) or child elements.
$_ = FluentDOM::create();
echo $_(
'ul',
['class' => 'navigation'],
$_('li', 'FluentDOM')
);<?xml version="1.0" encoding="UTF-8"?>
<ul class="navigation"><li>FluentDOM</li></ul>- Home
- Getting Started
- Tasks
- Plugins
- Functions
- Lists
- Creator (5.1)
- CSS Selectors
- Convertors
- Loaders
- Serializers (5.1)
- Transformers (5.1)
- Extended DOM
- XMLReader (6.1)
- XMLWriter (6.1)
- Interfaces