PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Aleksandrs Kornevs   Stidy   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Stidy
Reformat HTML tag indentation
Author: By
Last change:
Date: 17 years ago
Size: 1,579 bytes
 

Contents

Class file image Download
<fieldset>
<legend>Original html::Table beautifer</legend>
<form method="post">
<textarea cols=120 rows=20 name="orig">
<?php
error_reporting
(E_ALL);
if(isset(
$_POST['orig'])){
    echo
replace($_POST['orig']);
}else{
    echo
'&lt;table width="100%" border="0" cellspacing="0" cellpadding="4" &gt;&lt;tr&gt;&lt;td nowrap&gt;Hello there&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;';
}
?>
</textarea>
<input type="submit" value="Beautify">
</fieldset>

<?php
// ************************************************************
$time=utime();
// ************************************************************
require_once('class_stidy.php');
$stidy=new Stidy;

if(isset(
$_POST['orig']))echo '<textarea cols=120 rows=20>'.replace($stidy->parse($_POST['orig'])).'</textarea>';

// ************************************************************
echo 'time:'.(utime()-$time)."<br>";
// ************************************************************

// ************************************************************
// ************************************************************
function utime()
{
   
$time = explode( " ", microtime());
    return (double)
$time[1] + (double)$time[0];
}
// ************************************************************
function replace($html)
{
   
$html=(get_magic_quotes_gpc())?stripslashes($html):$html;
   
$html=htmlspecialchars($html,ENT_NOQUOTES);
// $html=str_replace('<','&lt;',$html);
// $html=str_replace('>','&gt;',$html);
// $html=str_replace('"','&quot;',$html);
// $html=str_replace("'","&#039;",$html);
   
return $html;
}
?>