<?php
namespace framework\src\cmd;
use framework\cao as cao;
final class str extends cao {
static protected function _echo_(){
$func_get_args = func_get_args();
if(!empty($func_get_args)){
foreach($func_get_args as $value){
if(is_string($value) || is_numeric($value)){
echo (string)$value;
}
}
}
}
static protected function _charset_( $data = NULL, $charset = '', $encoding_list = array() ){
if( empty($data) ){
return $data;
}
if( empty($charset) ){
$charset = mb_internal_encoding();
}else{
$charset = strtoupper($charset) }
if( empty($encoding_list) ){
$encoding_list = array(
'UTF-8', 'GB2312', 'GBK', 'ASCII',
'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 'ISO-8859-4', 'ISO-8859-5',
'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 'ISO-8859-10',
'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16',
'Windows-1251', 'Windows-1252', 'Windows-1254'
);
}
if( is_array($data) ){
foreach ($data as $key => $value){
$data[$key] = self::_charset_( $value ) }
}else
if(is_object($data)){
foreach($data as $key => $value){
$data->$key = self::_charset_( $value ) }
}else{
$encoding_type = mb_detect_encoding($data , $encoding_list);
if( $encoding_type != $charset){
$data = mb_convert_encoding($data ,$charset , $encoding_type);
}
}
return $data;
}
static protected function _addslashes_( $data = NULL ){
if( !isset($data) || $data == '' ){
return $data;
}
if( !get_magic_quotes_gpc() ){
if(is_array($data)){
foreach($data as $key => $value){
$data[$key] = self::_addslashes_( $value ) }
}else
if(is_object($data)){
foreach($data as $key => $value){
$data->$key = self::_addslashes_( $value ) }
}else{
$data = addslashes($data);
}
}
return $data;
}
static protected function _stripslashes_( $data = NULL ){
if( !isset($data) || $data == '' ){
return $data;
}
if(is_array($data)){
foreach($data as $key => $value){
$data[$key] = self::_stripslashes_( $value ) }
}else
if(is_object($data)){
foreach($data as $key => $value){
$data->$key = self::_stripslashes_( $value ) }
}else{
$data = stripslashes($data);
}
return $data;
}
static protected function _toupper_( $data = NULL ){
if( !isset($data) || $data == '' ){
return $data;
}
if( is_array($data) ){
foreach($data as $key => $value){
$data[$key] = self::_toupper_( $value ) }
}else
if( is_object($data) ){
foreach($data as $key => $value){
$data->$key = self::_toupper_( $value ) }
}else{
$data = strtoupper($data);
}
return $data;
}
static protected function _tolower_( $data = NULL ){
if( !isset($data) || $data == '' ){
return $data;
}
if( is_array($data) ){
foreach($data as $key => $value){
$data[$key] = self::_tolower_( $value ) }
}else
if( is_object($data) ){
foreach($data as $key => $value){
$data->$key = self::_tolower_( $value ) }
}else{
$data = strtolower($data);
}
return $data;
}
}
?>