A reference is the address of a memory location that has a value. However, there is no high-level computer language that allows you to type the hexadecimal number address of a memory location directly into a program. So each language goes about this in its own way. So the meaning of reference is slightly different in different languages. Each language goes about the implementation of reference in its own way. So, for each language, you have to learn the meaning of Reference and how it is used in that language coding. In this article, I introduce you to a tutorial series that explains the meaning and implementation (use) of reference in PHP.
You need to have basic knowledge in PHP, before starting the series.
At the moment, there are 4 parts to the series.
The First Part of the Series
The first part of the tutorial series introduces you to reference in PHP and explains the meaning of reference in PHP.
The Second Part of the Series
This part of the series explains how a function can return the reference to a value instead of returning the value, or returning the variable holding the value.
The Third Part of the Series
Still dealing with functions, this part explains how you can pass the reference of a value to a function instead of passing the value (or variable holding the value). It also explains what happens inside the function block.
The Fourth Part of the Series
You can unset a reference. Would you like to know what that means? You can spot a reference. I guess you would like to know what that means also. More about that in this part of the series!
Reasons for Learning PHP Reference
The use of reference economizes the use of memory, especially when the value of the reference is large. Imagine that you are dealing with a value that is the content of a long file. You should not really keep such value in more than one place in memory. Talking about the use of reference, there are times when you are interested in a value and not the variable that holds the value; in this case, use of reference is appropriate.
As indicated above, the tutorials are ready. The good news is that they are free. Even though they are free, they are well written. The formatting of the code samples is good, with good indentation. So the code samples are very readable. There is no missing special character, as you would find in other sites. The links to the different parts of the series are easily accessible in each page. Click the following link to start the series: