Hello list,
as you are familiar with the source code of php it might be easy to explain
how the brain of php interprets the following code:
print ($life = "hard") -1;
print "\nlife: {$life}\n";
Best regards,
Oliver
P.S. Actually, the origin of that code was the output of a string literal
concatenated with count($array) -1
print ($life = "hard") -1;
Store "hard" in $life,
Substract 1 from the result of that assignment ("hard")
"hard", when used in a string context is casted to int (0)
0 - 1 == -1
Output result of subtraction (casted to string): "-1"
print "\nlife: {$life}\n";
Concatenate "\nlife: " with contents of $life ("hard") and concatenate that
with "\n"
Output the result of concatenation
-Sara
Oliver Block wrote:
Hello list,
as you are familiar with the source code of php it might be easy to explain
how the brain of php interprets the following code:
I think that this would be better suited to the startard PHP list. I
would suggest posting any further followups there.
print ($life = "hard") -1;
($life="hard") assigns "hard" to $life and returns "hard"
"hard" -1 casts "hard" to an integer to do a math operation, "hard"
casts to 0
0 -1 is -1, so -1 is printed
print "\nlife: {$life}\n";
Now you simply print the value of $life, "hard"
David