2 # ============================
3 # filename: string.class.php
4 # note : 字符串管理
5 # update : 2008-5-8
6 # cool!!
7 # ============================
8 class qg_c_string
9 {
10 var $script = false ;
11 var $iframe = false ;
12 var $style = false ;
13
14 function __construct( $script = false , $iframe = false , $style = false )
15 {
16 $this -> script = $script ;
17 $this -> iframe = $iframe ;
18 $this -> style = $style ;
19 }
20
21 # [兼容php4]
22 function qg_c_string( $script = false , $iframe = false , $style = false )
23 {
24 $this -> __construct( $script , $iframe , $style );
25 }
26
27 function __destruct()
28 {
29 return true ;
30 }
31
32 # [设置状态属性]
33 function set( $var , $status )
34 {
35 $this -> $var = $status ;
36 }
37
38 function safe( $msg )
39 {
40 if ( ! $msg )
41 {
42 return false ;
43 }
44 if ( is_array ( $msg ))
45 {
46 foreach ( $msg as $key => $value )
47 {
48 $msg [ $key ] = $this -> safe( $value );
49 }
50 }
51 else
52 {
53 $msg = trim ( $msg );
54 $old = array ( & , , ' , ' ' , , \t , \r );
55 $new = array ( & , , ' , , < , > , , );
56 $msg = str_replace ( $old , $new , $msg );
57 $msg = str_replace ( , , $msg );
58 $old = array ( /