As a beginner in PHP, I have been confused about the reference of PHP for a long time. I carefully read the user manual and did some experiments tonight, and finally understood the principles and details, in particular, = operator for different types of behavior. First, explain the behavior of the value assignment operator =. let's look at the example below:
Th
First explain the behavior of the assignment operator =, see the following example:
Copy CodeThe code is as follows:
$i = 0;
$j = $i;
$j = 0;
Echo $j; Print output 0
$arr = Array (0);
$arr 2 = $arr;
$arr 2[0] = 1;
echo $arr [0]; Print output 0
Class B
{
Public $i = 0;
}
$b = new B ();
$c = $b;
$c->i = 1;
Echo ($b->i); Print Output 1
As can be seen from this example, if the variable on the right of the
Assignment and replication of objects: assignment: Overloading by the "=" operator
User A (a), B;
b = A;
Replication: Calling a copy constructor
User b;
User A (b);
Or
User A = b;//is equivalent to User A (b);
Unlike assignment, the assignment is to assign a value to an alre
First explain the behavior of the assignment operator = See the following example:
Copy Code code as follows:
$i = 0;
$j = $i;
$j = 0;
Echo $j; Print output 0
$arr = Array (0);
$arr 2 = $arr;
$arr 2[0] = 1;
echo $arr [0]; Print output 0
Class B
{
Public $i = 0;
}
$b = new B ();
$c = $b;
$c->i = 1;
Echo ($b->i); Print Output 1
As you can see fr
Operation
Assigning values to variables
result = expression
Parameters
Result
Any variable .
Expression
Any numeric expression .
Description
The = operator, like other operators, has a value in addition to assigning a value to a variable. This means that you can connect the assignment operations like this to write the following:
=== 0;
After the example statement is executed, the values of J, K,
Such as:String A ("Sky1"), B ("Sky2");b = A;The program creates two objects at run time, A and B, respectively, and then calls the constructor. When executing "b=a", because there is no user-defined assignment operator function, then the program automatically calls the default assignment function, two pointers to the same memory, "Sky2" the memory of this space s
Assignment operators in JavaAn assignment operator is a symbol that specifies a numeric value for a variable or constant. If you can use "=" to assign the result of the right expression to the left operand.Common assignment operators supported by Java, as shown in the following table:650) this.width=650; "src=" http://
[1] indirect reference of variables:
The output above is 123
We can see that there is another $ in the second line of code, and the variable is accessed through the specified name, the specified name is stored in $ a ('B, change the value of $ B to 123. Therefore, such $ B variables are created and assigned values.
By adding the $ tag before the variable, you can increase the number of references at will.
[2] connection string: concatenates a string into a new merged string by using a co
Using System; using System. collections. generic; using System. linq; using System. text; using System. IO; using System. runtime. serialization. formatters. binary; namespace CloneClass {class Program {static void Main (string [] args) {Results set1 = new Results (); Result result1 = new Result (); result1.ResultId = "1 "; result1.ResultName = "kp"; set1.ResultSetId = "Set1"; set1.result = result1; // The operator value is Results set2 = set1; // Res
Class string{PublicString (const char *str=null);String (const string str); Why is the parameter of the copy constructor a reference? I believe we all know!string operator= (const string str); Assignment function Why is the return value a reference?~string ();};If a value is returned, the copy constructor is called immediately after return *this.But if the copy constructor is not defined, the default copy
The following assumes variable A is 10 and variable B is:"=" is to assign the right value to the left variable .Example 1 : Programming Implementation 145893 Seconds is a few days a few hours a few minutes a few seconds? Total = 145893Day = Total // ( - * - * -)hour = ( Total % ( - * - * -)) // ( -* -)minute = ( Total % ( - * -)) // -second = Total % -Print("%dseconds to%ddays,%dhours,%dminutes,%dseconds" % ( Total, Day , Hour, minute, second))Example 2 : the user input Chinese, math
Operation
The value of the variable moves to the left, based on the number of digits specified in the expression value, and assigns the result to the variable
result expression
Parameters
Result
Any variable .
Expression
Any expression .
Description
Using the operator is equivalent to using the following statement:
result = result
The operator moves all bits of result to the left expression the number
This is a creation in
Article, where the information may have evolved or changed.
the keyword is omitted herevar, I like the way it is (you can write less code without any harm). But it's important to note that ": = "is to declare and initialize the variable, so the variable must be the first occurrence, and the following initialization is wrong. But be aware of the type you want to assign when assigning a value,Goimplicit conversions are not supported in the. If you are defining afloat64type of
This is a creation in
Article, where the information may have evolved or changed.
the keyword is omitted herevar, I like the way it is (you can write less code without any harm). But it's important to note that ": = "is to declare and initialize the variable, so the variable must be the first occurrence, and the following initialization is wrong. But be aware of the type you want to assign when assigning a value,Goimplicit conversions are not supported in the. If you are defining afloat64type of
Operation
Performs a bitwise OR on a variable value and an expression value and assigns the result to the variable.
result |= expression
Parameters
Result
Any variable .
Expression
Any expression .
Description
Using this operator is equivalent to using the following statement:
result = result | expression
The |= operator looks at the value of the binary notation of result and expression , and p
Operation
Adds a variable value to an expression value, and assigns it to the variable.
result += expression
Parameters
Result
Any variable .
Expression
Any expression .
Description
Use this operator to specify exactly the same as this:
result = result + expression
An underlined subtype in an expression determines the operation of the + = operator.
if
so
Two expressions are eit
Operation
Performs a bitwise XOR on a variable and an expression and assigns the result to the variable.
result ^= expression
Parameters
Result
Any variable .
Expression
an arbitrary expression .
Description
Using the ^= operator is equivalent to using the following statement:
result = result ^ expression
The ^= operator looks at the value of the binary representation of two expressions and perf
Chapter II, section 10th1, there can be only one variable on the left, and the left must be a variable2, Calculator WinForm1, drag the control (one button, two label, two textbox)2, double-click Write event for button3,result4, get the input text information5, select the button, switch to the lightning bolt check Click6, write method to click event7,{String S1=txtnum1.text;String S2=txtnum2.text;String s=s1+s2;Labelresult.text=s;}8, converts the input string to an integer addition{String S1=txtn
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.