| ||||||||||
Operßtory p°i°azenφZßkladnφm p°i°azovacφm operßtorem je "=". Mohli byste si zprvu myslet, ╛e se jednß o "rovnß se". Nikoliv. SkuteΦn∞ to znamenß, ╛e se levΘmu operandu p°i°adφ hodnota v²razu vpravo (tj. "nastav na", "p°i°a∩ do" atd.). Hodnotou v²razu p°i°azenφ je hodnota, kterß se p°i°azuje. Tj. hodnotou "$a = 3" je Φφslo 3. To vßm umo╛≥uje provßd∞t r∙znΘ triky: In addition to the basic assignment operator, there are "combined operators" for all of the binary arithmetic and string operators that allow you to use a value in an expression and then set its value to the result of that expression. For example:
Note that the assignment copies the original variable to the new one (assignment by value), so changes to one will not affect the other. This may also have relevance if you need to copy something like a large array inside a tight loop. PHP 4 supports assignment by reference, using the $var = &$othervar; syntax, but this is not possible in PHP 3. 'Assignment by reference' means that both variables end up pointing at the same data, and nothing is copied anywhere. To learn more about references, please read References explained. | ||||||||||
|