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 Html

Functions for HTML processing.

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: Jaroslav HanslĂ­k
Located at Html.php
Methods summary
final public
# __construct( )

Constructor preventing from creating instances of a static class.

Constructor preventing from creating instances of a static class.

Throws

LogicException
If trying to create an instance
public static boolean
# is( string $text )

Tests if the given text contains at least one HTML tag. It is just an estimation.

Tests if the given text contains at least one HTML tag. It is just an estimation.

Parameters

$text
string
Input text to be tested

Returns

boolean
public static string
# repair( string $html )

Fixes an invalid HTML source, unifies quotes and removes unnecessary whitespace. Required the Tidy PHP extension.

Fixes an invalid HTML source, unifies quotes and removes unnecessary whitespace. Required the Tidy PHP extension.

Parameters

$html
string
Input HTML source

Returns

string
public static string
# removeTags( string $html, array $tags = array() )

Removes given tags from the HTML source. If no tags are given, the default set is used. Expects valid HTML code.

Removes given tags from the HTML source. If no tags are given, the default set is used. Expects valid HTML code.

Parameters

$html
string
HTML source code
$tags
array
Tags to be removed

Returns

string
public static string
# removeInnerTags( string $html, string $tag )

Removes tags of the same type nested into each other from the HTML source. Expects valid HTML source

Removes tags of the same type nested into each other from the HTML source. Expects valid HTML source

Parameters

$html
string
HTML source code
$tag
string
Tags to be processed

Returns

string
public static string
# removeAttributes( string $html, array $attributes = array() )

Removes given attributes from the HTML source. If no attributes are given, the default set will be used. Expects valid HTML source.

Removes given attributes from the HTML source. If no attributes are given, the default set will be used. Expects valid HTML source.

Parameters

$html
string
HTML source code
$attributes
array
Attributes to be removed

Returns

string
public static string
# removeJavascriptEvents( string $html )

Removes all javascript events from the HTML source. If it is necessary to remove only certain events, the removeAttributes() method can be used. Expects valid HTML source.

Removes all javascript events from the HTML source. If it is necessary to remove only certain events, the removeAttributes() method can be used. Expects valid HTML source.

Parameters

$html
string
HTML source code

Returns

string
public static string
# removeRemoteImages( string $html )

Removes foreign images from the HTML source. Keeps <img> tags (only set the value about:blank into its src attribute), because removing the tag entirely could affect the page layout. Expects valid HTML source.

Removes foreign images from the HTML source. Keeps <img> tags (only set the value about:blank into its src attribute), because removing the tag entirely could affect the page layout. Expects valid HTML source.

Parameters

$html
string
HTML source code

Returns

string
public static string
# removeDangerous( string $html )

Removes possibly dangerous attributes that could contain XSS code from the HTML source.

Removes possibly dangerous attributes that could contain XSS code from the HTML source.

Parameters

$html
string
HTML source code

Returns

string
public static string
# getBody( string $html )

Returns <body> contents from the given HTML source. Expects valid HTML source.

Returns <body> contents from the given HTML source. Expects valid HTML source.

Parameters

$html
string
HTML source code

Returns

string
public static string
# fromText( string $text, boolean $convertLinks = true )

Converts text to HTML source code.

Converts text to HTML source code.

Parameters

$text
string
Input text
$convertLinks
boolean
Convert urls and emails to links

Returns

string
public static string
# linkFromText( string $text )

Converts text to a link to an url or email.

Converts text to a link to an url or email.

Parameters

$text
string
Input text

Returns

string
public static string
# toText( string $html )

Converts HTML source code to plaintext.

Converts HTML source code to plaintext.

Parameters

$html
string
HTML source code

Returns

string
Jyxo PHP Library API documentation generated by ApiGen 2.3.0