PHP Interview Problem Collation Collection

Source: Internet
Author: User

1. I believe that everyone is not unfamiliar with memcache, in the project also often use memcache as a caching scheme, then in the use of the process has not found why Memcahce has two ways to add the cache: One is add, one is set, then you know what the 2 methods are different? When should I use Add? When should I use set?

To this point, I did not go into the drill, only know to add the cache with set, as if most of the time is used by the Set method, and add seems to be seldom used. I talked to a friend a few days ago about this, and tonight here's a record of the differences between the 2 methods.

1), Memcache::add method: The Add method is used to add a data to the Memcache server to be cached.

Note: If the key to be stored already exists in the Memcache server, the Add method call fails at this time.

2), Memcache::set method: The Set method is used to set the cache content of a specified key, and the Set method is the aggregate of the Add method and the Replace method.

3), Mmecache::replace method: The Replace method is used to replace the cached content of a specified key, and returns False if key does not exist

Attention:

A) If the key to be set does not exist, then the set method has the same effect as the Add method;

b), if the key to be set already exists, the set method is the same as the Replace method.

Dynamic variables in 2.PHP and

/**
* Dynamic Variable
* That is, the name of the variable, or it can be a variable;
**/

$str = ' Hello ';
$hello = ' Hello word ';
Echo $str. ' <br/> '; Hello
Echo $hello. ' <br/> '; Hello Word
The two ' $$ ' notation is to turn $str value into a variable, so output ' hello word ';
echo $ $str. ' <br/> '; Hello Word

3. What are the conditions for buffer overflow? What consequences will it cause?

Value passing and reference passing in 4.PHP

Pass value: The argument is assigned to the parameter, and the parameter is changed without affecting the value of the argument.

Reference: The real address of the way to pass parameters, after passing, the real participation of formal parameters are the same object, but the name is different, the change of the parameter, will affect the value of the argument.

<?php

Pass Value

$a = 3;

$b = 4;

function num ($a, $b) {

return $a + $b;

}

echo num ($a,& $b);

Pass Reference

Function Nums (& $d) {

$d + +;

return $d;

}

$c = 3;

Echo Nums ($c);

?>

PHP Interview Problem Collation Collection

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.