In PHP, strings can be represented in three ways:
1. Single quotation marks
2. Double quotes
The difference between single and double quotes is that the contents of the variable in the single quotation mark are output as normal character content, and the variables in the double quotation marks are replaced with the values of the variables to output.
$name = "Joedlut"; $str = ' name is $name ', $str 2 = "name is $name"; Echo $str 1; Name is $nameecho $STR 2; Name is Joedlut
3. Use the delimiter <<< delimiter to define large formatted text, that is, the formatting in the text is preserved, and the text does not need to use escape characters.
The format is as follows
<<<str
formatting text
Str
<?php $str = "Tomorrow's Technology Dictionary", Echo <<<strmark <font color= "#FF0099" > $str listing, for details, please pay attention to the programming dictionary network: Strmark;? >
Note: Annotations cannot appear in delimiters. The starting and ending delimiters must be identical. The variables in formatted text are similar to double quotes and are replaced with the contents of variables.
===================================================================================
How do I connect strings?
Use. Note that the plus sign is not
$str 1 = "Hello"; $str 2 = "World"; Echo $str 1. $str 2;//helloworld
===================================================================================
Manually escaping a string
Manual escape is required when characters such as "" are included in the string
Echo ' select * from user where name=\ ' PHP project development record \ ';
A string with a large amount of data can be escaped by escaping the function
Addslashes ()
To escape the ' "null character 0 by adding \ to the string
String addslashes (String str)
$STR = "SELECT * from book where name= ' Java Development combat '"; $a = addslashes ($STR); Echo $a;
2.string stripslashes ($STR)
To restore a string by applying the Stripslashes () function
$b = stripslashes ($a); Echo $b;
Note: Before all data is inserted into the database, it is necessary to escape the data using Addslashes (), in a way that the special characters are not escaped when inserting the database with an error.
====================================================================================
Gets the length of the string
int strlen (string str);
Intercept string
String substr (string str,int start,int length);
Retrieves whether needle has occurred in haystack
String Strstr (string haystack,string needle);
Retrieving the number of occurrences of needle in haystack
String Substr_count (String haystack,string needle)
This article is from the "thick Product Thin Hair" blog, please make sure to keep this source http://joedlut.blog.51cto.com/6570198/1853812
PHP Rookie (4) string