Definition and processing of strings

Source: Internet
Author: User
\ N carriage return \ r line feed \ t carriage return 1. definition: Double quotation marks: A. variables can be executed in double quotation marks, for example, $ num = 1000; $ STR = "It is my $ num life"; echo $ STR; in this case, it is output "My 1000 life", indicating that variables can be identified in double quotation marks. However, if you want to execute the above method normally, add a space before and after the variable, write the variable as $ {num}, or use it according to the rules in PHP ". "will be connected before and after. B. You can use the Escape Character $ STR = "This Is A \" string \ "test"; defined in single quotes: a. Variable B cannot be executed in single quotes. only partial escape characters can be used. escape characters can be used before single quotes. The "\" character can be used to escape the characters defined by anti-quotation marks: $ STR = 'aaaaaaaaa'; // No error occurs, but the server command is not output in the backquotes. If the server is Linux, the Linux command can be used, for Windows, it can be a Windows command, for example, $ STR = "ipconifg/all"; echo $ STR; the delimiter defines: "<", $ STR =
$ Pos1 = strrpos ($ URL, "/") + 1;
$ STR = substr ($ URL, $ pos1 );
$ Pos2 = strpos ($ STR ,"? ");
$ STR = substr ($ STR, 0, $ pos2 );
Echo $ STR; Output demo. php
Str_pad (the string to be processed, the length of the string after processing, the string to be filled, and the direction to fill): String filling function,
The fourth parameter has three constants: str_pad_left, left filled
Str_pad_right: Fill on the right
Str_pad_both: Fill both sides
$ STR = "www.baidu.com"; $ str2 = str_pad ($ STR, 30, "#", str_pad_left); string comparison: String comparison by byte strcmp () strcasecmp () compare the fuzzy comparison of strnatcmp () strings by natural sorting without case sensitivity soundex () returns the number of matching str_replace (string str1, string str2, string str2, string str3) replace str1 in str3 with str2 str_replace (array arr, string str2, string str3) str_replace (array arr1, array arr2, string str3) strtr (string STR, string from, string to) string translation function, which replaces strtr (string STR, array ARR) $ STR = "http://www.baidu.com "; $ arr = array ("HTTP"-> "ftp", "Baidu"-> "google"); $ newstr = strtr ($ STR, $ ARR); stripslashes () remove the Escape Character addslashes () htmlentities () for processing HTML tags htmlspecialchars () strip_tags () Forcibly Delete the HTML Tag strip_tags (STR, tags ): strip_tags ("<B> DD </B>", "<B> <I>") This Code indicates that, other functions such as parse_str () parse_url () URL encoding handler: rawurlencode (); urlencode () urldecode () to construct query strings: http_build_query ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.