Home >Backend Development >PHP Problem >Don't think that you don't need to learn C language to do PHP
The reason why I say "Don't think that learning PHP does not require learning C language" is because you only learn PHP without any basic languages such as C language. It is difficult to deeply understand many things in PHP without the support.
There are actually many such examples. Here I will give you this example: the difference and connection between PHP arrays and C language arrays.
Friends who have studied C language certainly know that there are arrays in C language;
There are also arrays in PHP, but their functions are almost completely different. PHP has too many arrays and is very easy to use. function. So what's the reason? Are there many kinds of arrays and you just learn one of them? Actually not.
The fundamental reason is: the array in C language is a real array, which is a continuous storage space applied for on the stack. Once this kind of space is applied for, you cannot add an element or delete an element. It can only be operated as a whole, either delete it all, or re-apply for an array. This is a real array.
The array in PHP is actually not such an array. It applies for memory in the heap, then uses a pointer to point to the head address, and then traverses the pointer, so that a certain element can be deleted and a new one can be added at any time. elements, because it is no longer a real array in nature, but a linked list.
So it can be seen from here that C language is of great significance to the understanding and learning of PHP. Without the linked list support of C language, the features of PHP will appear inexplicably, and you will always feel that you have no place to stand despite your fantasies.
The linked list principle in C language is the principle basis for realizing vector, list, map, and other dynamic arrays, linked lists, sets, and queues in C. It is also the principle basis for realizing arrays in PHP (essentially dynamic arrays implemented by linked lists). ) principle basis.
Then the understanding of the complex data structures of the upper-layer language will become logical. The operations on PHP arrays become easy to understand. For example:
Insert an element at the end:
##Pop up an element:The above is the detailed content of Don't think that you don't need to learn C language to do PHP. For more information, please follow other related articles on the PHP Chinese website!