CssToInlineStyles class

__construct

Creates an instance, you could set the HTML and CSS here, or load it later.

Parameters

html string (optional)
The HTML to process
css string (optional)
The CSS to use

Return

void

convert

Converts the loaded HTML into an HTML-string with inline styles based on the loaded CSS

Return

string

Example

<?php
// require
require_once 'css_to_inline_styles.php';

// create instance
$cssToInlineStyles = new CSSToInlineStyles('<the-html-to-process-as-a-string>''<the-css-to-use>');

// grab the processed HTML
$processedHTML $cssToInlineStyles->convert();

?>

setCleanup

Should the IDs and classes be removed?

Parameters

on bool (optional)

Return

void

setCSS

Set CSS to use

Parameters

css string
The CSS to use

Return

void

setHTML

Set HTML to process

Parameters

html string

Return

void

setUseInlineStylesBlock

Set use of inline styles block
If this is enabled the class will use the style-block in the HTML.

Parameters

on bool (optional)

Return

About me?

Well, I'm Tijs Verkoyen, a Belgian PHP-developer at Netlash. In my spare time I run my own company called CR Solutions.

If you want to know more about me, check my blog (Dutch).

Spoon

At both companies, we use Spoon. Spoon is a PHP5 Library that we use for building all our Web 2.0 applications.

The classes that you can download from this website are standalone, so each developer is free to use a library/framework/… he likes best.

If you really like my work and want to support me, feel free to use the donate-button below.