<?php
class String {
public static function ltrimDemo($str)
{
echo ltrim($str)."</br>";
}
public static function rtrimDemo($str)
{
echo rtrim($str)."</br>";
}
public static function trimDemo($str,$char)
{
echo trim($str,$char)."</br>";
}
public static function str_padDemo($str,$length,$pad=" ",$type=STR_PAD_BOTH)
{
echo str_pad($str,$length,$pad,$type)."</br>";
}
public static function uppperlow($str)
{
echo"strtoupper :". strtoupper($str)."</br>";
echo "strtolower :".strtolower($str)."</br>";
echo "ucfirst :".ucfirst($str)."</br>";
echo "ucwords :".ucwords($str)."</br>";
}
public static function html($str)
{
echo "nl2br :".nl2br($str)."</br>";
echo "htmlspecialchars :".htmlspecialchars($str)."</br>";
echo "htmlentities :".htmlentities($str,ENT_QUOTES,"gb2312")."</br>";
}
public static function stripslashesDemo($str)
{
echo stripslashes($str)."</br>"; //表单提交 ' " 都会默认加上 \ ,该函数作用就是去除 \,一般再和htmlspecialchars联合使用.
//addslashes 是为 单引号,双引号加上 反斜杠
}
public static function strip_tagsDemo($str)
{
echo strip_tags($str)."</br>"; //去除 html , javascript 标记等 ,
}
public static function readFile()
{
$str=file_get_contents("F:\\list.java");
echo nl2br(htmlentities($str,ENT_QUOTES,"gb2312"));
}
public static function strstrDemo($str,$search)
{
echo strstr($str,$search);
}
}
?>