PHP Classes
elePHPant
Icontem

File: String.test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Diogo Souza da Silva  >  String  >  String.test.php  >  Download  
File: String.test.php
Role: Example script
Content type: text/plain
Description: Examples and tests
Class: String
Encapsulation of string manipulation functions
Author: By
Last change:
Date: 7 years ago
Size: 1,902 bytes
 

Contents

Class file image Download
<?php
include("../../lang/String.class.php");
?>
First Test<br><br>
<?
$str
= new String("Diogo Souza"); // Creates a string
$str->concat(" da Silva"); // Concat a string
echo "String : ". $str."<br>"; // Echos normal
$str->stripSpaces(); // Take spaces out
echo "Spaces striped out and to upper case: ".$str."<br>" ; // Echo
$r = $str->undo()->explode(" "); // undo last changes, chain divide ( same as explode)
echo "Result 0 of divide/explode : ".$r[0]."<br>"; // To test
echo "Actual String, after undo: ".$str."<br>" ;
echo
"Actual String, after redo: ".$str->redo()."<br>" ;
echo
"String contains 'da'? ".$str->undo()->contain("da")."<br>"; // If contais string
echo "String contains 'Da'? ".$str->contain("Da")."<br>"; // It is case sensitive
echo "(insensitive)String contains 'Da'? ".$str->contain("Da",true)."<br>"; // Case insensitive
echo "How string is: ". $str->undo();
?>
<br><br><br>
URL vs String <br><br>
<?
$str
= new String("http://www.manifesto.blog.br/teste de<b> possíveis </b> problemões aqui");
echo
"Start String: ".$str."<br>" ;
echo
"Url encoded: ".$str->toUrl()."<br>";
echo
"Html encoded: ".$str->htmlEncode()."<br>";
echo
"Html encoded, only words(no tags encoded): ".$str->undo()->htmlEncodeWords()."<br>";
echo
"Cleaned-up: ".$str->undo()->clean()."<br>";
$str->undo();
?>
<br><br><br>
Just undo and redo, and basic stuff<br><br>
<?
$str
= new String("Teste Simples OK!");
echo
"String: ".$str."<br>" ;
$str->upperCase();
echo
"String upperCase(): ".$str."<br>" ;
$str->undo() ;
echo
"Echo and undo: ".$str."<br>";
$str->redo() ;
echo
"Echo and redo: ".$str."<br>";
$str->lowerCase()->upperCaseFirst();
echo
"String lowcase + upperCase1st(): ".$str."<br>" ;
echo
"Echo and undo(2): ".$str->undo(2)."<br>";
echo
"Echo and redo(2): ".$str->redo(2)."<br>";
echo
"Echo and undo 3x: ".$str->undo(1)->undo()->undo()."<br>";

?>