PHP notes One

Source: Internet
Author: User

The first time to write a blog is very tense, sure enough to work when the brain more clear-minded. I am just a rookie, and there is no outline, presumably belongs to the scope of entertainment, light spray.

Well, the first blog post on the water reference and the value is good, this everyone knows ah, there is nothing good water, I don't care I don't care, I will send.

First two examples

 <? php   $a  = array  ( (' id ' = = 1, ' name ' = ' Zhangsan '), array  (' id ' = = 2, ' name ' =&G T    ' Lisi '), array  (' id ' = = 3, ' name ' = ' Wanwu '  $v  [' id '  $v  [' name ']. "    SSSs ";  print_r  ( $a ); 
<? PHP     $a = ' Hello ';     $b = &$a;     $b = "word";     Echo $a,$b;

Well, good side, just went to Baidu a bit, sure enough to find a lot. (Pretend you didn't see it).

These two examples can see that the value of $ A is changed, because $ A actually points to the address of the variable, and then $b, $v, is assigned to the same address, so when $b, $v change the time $ A changed.

It is worth mentioning that the variable name of the array in C is pointed to the first variable of the array, do not know PHP is not, but PHP does not have the concept of pointers, bad test, I found that the concept of PHP memory is so vague. Baidu a bit found SHMOP can operate memory, back to the virtual machine to try.

And the memory of the PHP storage variables is actually pre-allocated, leaving a bit empty. Memory_get_usage () can view PHP memory consumption balabala. It's easy to test it out. For example, I was testing $a= "s" and $a= "Sssssss" when PHP consumes the same amount of memory, but $a= ' Sssssssa ' more than one character is occupied by the memory will suddenly more than 16 bytes.

About this I have seen in the design and implementation of Redis introduction

That's it, let's do it, read more books, the next chapter is interesting.

PHP notes One

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.