Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • Charset
  • Color
  • Css
  • ErrorHandler
  • ErrorMail
  • FirePhp
  • Html
  • HtmlTag
  • SpamFilter
  • String
  • Timer
  • XmlReader

Exceptions

  • Exception
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated

Class HtmlTag

Class for generating (x)HTML source code. Allows creating HTML tags and its attributes.

Example:

$p = \Jyxo\HtmlTag::create('p')->setClass('buttons');

The magic __call() method ensures attributes settings.

$p->render();

The render() method creates the HTML output.

Final
Namespace: Jyxo
Category: Jyxo
Package: Jyxo\Html
Copyright: Copyright (c) 2005-2011 Jyxo, s.r.o.
License: https://github.com/jyxo/php/blob/master/license.txt
Author: Roman Řáha
Author: Štěpán Svoboda
Located at HtmlTag.php
Methods summary
public static Jyxo\HtmlTag
# create( string $tag )

Creates an element instance.

Creates an element instance.

Parameters

$tag
string
HTML element name

Returns

Jyxo\HtmlTag
public static Jyxo\HtmlTag
# createFromSource( string $html )

Returns an element instance from the given source. The first and last tag will be used as the opening and closing tag respectively. Anything between those tags will be used as contents.

Returns an element instance from the given source. The first and last tag will be used as the opening and closing tag respectively. Anything between those tags will be used as contents.

Parameters

$html
string
HTML source code

Returns

Jyxo\HtmlTag

Throws

InvalidArgumentException
If an invalid HTML source was given
public string
# open( )

Creates and returns the opening tag.

Creates and returns the opening tag.

Returns

string
public string
# content( )

Creates and returns element's contents.

Creates and returns element's contents.

Returns

string
public string
# close( )

Creates and returns the closing tag.

Creates and returns the closing tag.

Returns

string
public string
# render( )

Renders the element.

Renders the element.

Returns

string
public Jyxo\HtmlTag
# addChild( Jyxo\HtmlTag $element )

Adds a child element.

Adds a child element.

Parameters

$element
Jyxo\HtmlTag
Child element to be added

Returns

Jyxo\HtmlTag
public Jyxo\HtmlTag
# addChildren( array $elements )

Adds multiple child elements.

Adds multiple child elements.

Parameters

$elements
array
Array of child elements

Returns

Jyxo\HtmlTag
public Jyxo\HtmlTag
# setAttributes( array $attributes )

Imports attributes from the given array.

Imports attributes from the given array.

Parameters

$attributes
array
Associative array of attributes and their values

Returns

Jyxo\HtmlTag
public Jyxo\HtmlTag
# setNoEncode( string $attribute )

Sets an attribute to not be espaced on output.

Sets an attribute to not be espaced on output.

Parameters

$attribute
string
Attribute name

Returns

Jyxo\HtmlTag
public Jyxo\HtmlTag
# setContentOnly( boolean $contentOnly )

Sets if only the contents should be rendered.

Sets if only the contents should be rendered.

Parameters

$contentOnly
boolean
Should only the contents be rendered

Returns

Jyxo\HtmlTag
public string
# __toString( )

Renders the HTML element.

Renders the HTML element.

Returns

string
public mixed
# __call( string $method, array $args )

Sets or returns the attribute.

Sets or returns the attribute.

Parameters

$method
string
Method name
$args
array
Method attributes

Returns

mixed
string|Jyxo_HtmlTag
public mixed
# __get( string $name )

Returns an attribute value.

Returns an attribute value.

Parameters

$name
string
Attribute name

Returns

mixed
string|null
Jyxo PHP Library API documentation generated by ApiGen 2.3.0