How to use PHP escape characters to solve code conversion problems. After learning the system: linuxphp4oracle8i? -- Input the title, name, and other fields into the database (with spaces at the beginning and end) functiontrans_string_trim ($ str) {$ strtrim ($ str); $ streregi_replace (after learningSystem: linux php4 oracle8i
-
- // -- Import the title, name, and other fields into the database (with spaces at the beginning and end)
- Function trans_string_trim ($ str ){
- $Str=Trim($ Str );
- $Str=Eregi_replace("'", "'' ", $ Str );
- $Str=Stripslashes($ Str );
- Return $ str;
- }
-
- // -- Process the input of an article, that is, the textarea field;
- Function trans_string ($ str ){
- $Str=Eregi_replace("'", "'' ", $ Str );
- $Str=Stripslashes($ Str );
- Return $ str;
- }
-
- // -- Display the data in the form from the library; convert the data in text to trans. in textarea, the data is directly displayed without conversion.
-
- // -- Display the HTML code on the WEB page, including the link address
- Function trans ($ string ){
- $String=Htmlspecialchars($ String );
- $String=Ereg_replace(Chr (10 ),"<Br>", $ String );
- $String=Ereg_replace(Chr (32), "", $ string );
- Return $ string;
- }
-
- // -- Display on the WEB page without filtering HTML code;
- Function trans_web ($ string ){
- $String=Ereg_replace(Chr (10 ),"<Br>", $ String );
- $String=Ereg_replace(Chr (32), "", $ string );
- Return $ string;
- }
-
- // -- Display HTML code and leading and trailing spaces on the WEB page, mainly used to display user nicknames
- Function trans_trim ($ string ){
- $String=Trim($ String );
- $String=Htmlspecialchars($ String );
- $String=Ereg_replace(Chr (10 ),"<Br>", $ String );
- $String=Ereg_replace(Chr (32), "", $ string );
- Return $ string;
- }
-
- // -- Display in span;
- Function trans_span ($ string ){
- $String=Ereg_replace(Chr (10), "n", $ string );
- $String=Ereg_replace(Chr (32), "", $ string );
- $String=Ereg_replace('"'," ", $ String );
- Return $ string;
- }
-
- // -- Display cookies on the WEB to filter html
- Function trans_cookie ($ str ){
- $Str=Trans($ Str );
- $Str=Stripslashes($ Str );
- $Str=Eregi_replace("'' "," '", $ Str );
- Return $ str;
- }
- ?>
Finally, let's add a bit more about the usage of the PHP escape character. if a section in the article is displayed in span, when using substr to take a fixed-length string, remember to add a space after the span parameter, otherwise, html code will be messy when half of Chinese characters are captured.
The above is the solution to the code conversion problem with PHP escape characters.
Ghost system: linux php4 oracle8i? // -- Input the title, name, and other fields into the database (with spaces at the beginning and end) functiontrans_string_trim ($ str) {$ str = trim ($ str ); $ str = eregi_replace ("'"...