Bifalgorithm post · Computer science one · Basics
How are PHP strings copied and modified by character?
How are PHP strings copied and modified by character? (Computer science one · Basics) — "The assignment operator can also be used to make copies of strings.\n\…
Ideas in this flowchart
- String copying and character modification with the assignment operator
- The assignment operator can copy a string.
- The copy is deep, so changes to the first string do not affect the second.
- $firstName = "Thomas";\n$alias = $firstName;
- Individual characters can be changed by treating a string like an array.
- String positions use zero-based indexing.
- $a = "hello";
- $a[0] = "H";\n$a[5] = "!";
- The string becomes "Hello!".