Variables in PHP:
1. Define: $ symbol to define the variable
2. Description:
(1) PHP weak language, when defining variables without declaring the type, but does not mean that PHP does not have a data type
(2) Variable names are case-sensitive and can only be numbers, letters, or underscores
(3) The variable defaults to the value assignment, which means that two variables are completely independent after the assignment
$a = "string"; $b $a and pass the value over , and there's noeffect between $a and $b .
(4) PHP also provides another way to assign a value----a reference assignment, when you pass an address
<? PHP $foo = ' Bob '; // Assign ' Bob ' to $foo $bar $foo ; // by $bar reference $foo $bar = "My name is $bar "; // Modifying $bar variables Echo $bar ; Echo $foo ; // the value of the $foo is also modified ?>
(5) Globle $a; Used to define global variables, which are used in the body of the function (the function body does not call global variables by default) in PHP string:
1. Definition: Double quotation marks ("") and single quotation marks (') to define a string
"String":
(1) PHP will parse some special characters (escape characters)
(2) Variables in string form will also be parsed
$str = 1; Echo "This is {$str} a string";
Results:
This is a string of 1
' String ':
Just a simple string with no corresponding parsing capability
2. Common methods
String length: strlen (String);
Comparison string: strcmp (string1,string2)----Case-sensitive, returns 0 (same) and 1 (not the same); STRCASECMP (STRING1,STRING2);----case insensitive, returns 0 (same) and 1 (not the same)
Convert Case: Strtolower (String),----to lowercase, strtoupper (string),----to uppercase;
PHP Learning (i)