Home >Backend Development >PHP Tutorial >photoshop learning video php learning string courseware

photoshop learning video php learning string courseware

WBOY
WBOYOriginal
2016-07-29 08:38:16783browse

Grammar
String string can be defined in three ways
' '(single quote) "" (double quote) <<<(delimiter)
The escape sequence can be interpreted as
The biggest feature of double quotes Yes The variable name will be replaced by the variable value
The delimiter can be output as it is in html format
There are two ways to print a string
echo It is a language structure, not a real function. The difference between it and print is that it can accept multiple parameters
print Syntax bool (Boolean line) print (string agr) The secondary function outputs a string. If successful, return 1. If failed, return 0. For example, if the customer's browser suddenly hangs during transmission, it will cause a failure. String processing function
ltrim Syntax format :string ltrim(string str); Delete the leading spaces of the string
rtrim Grammar format: string rtrim(string str); Delete the suffix spaces of the string
trim Grammar format: string rtim(string str); Delete both ends of the grandfather thread Space
strrev Grammar format: string strrev(string str); Reverse the string Turn the string upside down
strtolower Grammar format: string strtolower (string str); Change all strings into lowercase
strtoupper Grammar format: string strtoupper (string str ); Change all strings to uppercase
ucfirst Syntax format: string ucfirst(string str); Change the first letter of the string to uppercase
ucworde Syntax format: string ucworde(string str); Change the character of each character in the string Change the first letters to uppercase
Format the string for display
sprintf This function formats the string
sprintf() Syntax format string sprintf(string format,mixed[args]...)
Example:
$a=sprintf ("%'*6s","kkk")
echo $a;
Output result: ***kkk
b Convert integer to binary.
c Convert the integer into the corresponding ASCII character.
d Convert integer to decimal place.
f Convert single precision numbers to floating point numbers.
o Convert an integer to octal.
s Convert to string.
x Convert integer to lowercase hexadecimal.
X Convert integer to uppercase hexadecimal.
printf output formatted string return value integer
Syntax format: int printf(string format, mixed [args]...);
Example
printf("%d--%s--%x",72,72 ,72);
Output results: 72--72--48
Split and spell strings
explode syntax format: array explode (string separator, string string [, int limit])
implode syntax format: string implode(shring glue, array pieces) to connect the array function into a string
String comparison
strcmp syntax format: int strcmp(string 1, string 2) The return value is an integer substring
strcmp sub-string is used to compare the size. Negative number means 1 is less than 2 Positive number means 1 is greater than 2 0 means equal
strlen syntax format: int strlen(string str); Get the string length return value integer
substr syntax format: string substr(string string, int start, int [length]);
Get part of the string. String is a string. Take a few characters from the start to the stop. If the stop is omitted, go to the end. If the start is set to a negative number, it means taking from the back to the front. strstr string strstr(string haystack, string needle); Return to the string From the beginning of a certain string to the end of the string, that is to say, taking a certain point as the boundary to get the next segment of the string
strrchr Syntax format: string strrchr(string haystack, string needle); Get the last position of the string and intercept the characters from the back to the front If the string is not found, return false
strpos Syntax format: int strpos(string haystack, string needle, int [offset]); Searching for the first position of the string starts from 0 by default. If not found, return false
strrpos Syntax format: int strrpos (string haystack, char needle); Find the last occurrence of the string. Return false if not found. Return value integer
String padding
str_pad syntax format Can be used to protect some sensitive information
str_pad($input, 10); produces "Alien " "
str_pad($input, 10, "-=", STR_PAD_LEFT); // produces "-=-=-Alien"
str_pad($input, 10, "_", STR_PAD_BOTH); // produces " __Alien___ "
Str_pad ($ input, 6," ___ "); // Produces" alien_ "
"
"
" Replace the rStr_replace () function Replacement
There are three methods
str_replace("l","@","hello"); //What to replace What to replace Who to replace
$arr2=array("%color%","%title%","% body%");
$arr3=array("red","hello","world");
echo str_replace($arr2,$arr3," %body%");
How to touch the version
String translation
strtr() is an important replacement function also called string translation
strtr also has two calling methods
strtr(string $str, string $ from, string $to)
$arr5=array("hello"=>"hi","hi"=>"hello");
echo strtr("hello is hi",$arr5);
is the What is translated to
strtr(string $str, array $replace_pairs)
html processing
HTML entity processing
htmlentities(); (specify conversion mode and character set encoding)
ENT_COMPAT (default): Specify conversion of double quotes but retain single quotes Quotes
ENT_QUOTES: Indicates converting double quotes and single quotes at the same time
ENT_NOQUOTES: Indicates neither is converted
htmlspecialchars(); (Convert special symbols such as <> into entities<>)
Grammar format
$str= "

China

";
echo htmlentities($str); //Convert encoding
echo htmlentities($str,ENT_QUOTES,"EUC-JP");//Single Both quotation marks and double quotation marks are converted, followed by the encoding of the word
Processing of quotation marks
stripslashes(); (It is the inverse function of addslashes, showing the transferred characters)
addslashes(); (Put ' ” NULL(Processing URLs mainly includes:
Parsing of URL strings
parse_str(); (parse the request string into an array)
parse_url(); (parse the complete URL into an array)
URL encoding processing
rawurlencode(); ( Replace all non-alphanumeric characters into % followed by two hexadecimal digits)
urlencode(); (Replace all non-alphanumeric characters into % followed by two hexadecimal digits, and spaces become + signs)
rawurldecode(); (parse and restore %-encoded URLs)
urldecode(); (parse and restore %##-encoded URLs)
Construct query strings, etc.
http_build_query(); (Generate the request string after url-encoded)
 php学习 字符串课件php string.rar

The above introduces the photoshop learning video and php learning string courseware, including the content of photoshop learning video. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn