php interview,PHP interview questions

RESTful What is it?

RESTFUL It is a kind of design style and development method of network application program ,RESTFIL Is based on http Of .

It is mainly suitable for interface business development .

common API Of APP_ID APP_SECRET What's the main function ? Describe the process

app_id, app_key, app_secret: My ID card , Bank card number , Bank card password

JSON and JSONP The difference between

JSON Incoming data , by JSONP To cross domain .

encryption Signature Signcryption difference

encryption It's a special algorithm to change the original Information data , Make unauthorized user Even if you get encrypted Information, But because I don't know Decrypt Methods , Still unable to understand the content of the information .

Signature( also called Public key digital signature 、Electronic signature)

It's like a normal physical signature written on paper , But it uses the technology in the field of public key encryption , Methods used to identify digital information . A set of digital signatures usually defines two complementary operations , One for signing , Another for verification .

digital signature , It's a digital string that can only be generated by the sender of information and can't be forged by others , This digital string is also an effective proof of the authenticity of the information sent by the sender .

Signcryption

In information security , In order to ensure the confidentiality of information at the same time 、 integrity 、 Security elements such as authenticity and non repudiation , The traditional way is to get the message “ Sign first and encrypt later ” , The computation and communication cost of this method is the sum of the cost of encryption and signature , So it's inefficient .

So , In recent years, people begin to study digital signcryption system . That is, in a logical step , Sign and encrypt information at the same time . Its core The core value is to reduce the total computation and communication cost of encryption and signature .

RSA

RSA Is the most influential public key encryption algorithm ..RSA The algorithm is based on a very simple number theory fact : It's very easy to multiply two prime numbers , But it was very difficult to factorize the product , Therefore, the product can be disclosed as the encryption key

RESTful API Version control strategy

API The common version control strategies are 3 Patterns :

The first one is :The Knot: No version , It's the platform API There will always be one version , All users must use the latest API, whatever API All the changes will affect all the users of the platform . Even the entire ecosystem of the platform .

The second kind :Point-to-Point: Point to point , It's the platform API Version comes with version number , Users choose to use the corresponding API, Need to use new API characteristic , Users have to upgrade themselves .

The third kind of :Compatible Versioning: Compatibility version control , and The Knot equally , There is only one version of the platform , But the latest version needs to be compatible with the previous version of API Behavior .

OAuth 2.0 A simple explanation of

OAuth 2.0 It's the most popular authorization mechanism , Used to authorize third-party applications , Get user data .

In short ,OAuth It's a kind of authorization mechanism . The owner of the data tells the system , Agree to authorize third party applications to enter the system , Get the data . The system then generates a short-term entry token (token), In place of a password , For third party applications .

php The singleton pattern

However, in PHP in , All variables, whether global or static members of a class , It's all page level , Every time a page is executed , Will recreate new objects , Will be cleared after page execution , It seems that PHP The singleton model doesn't make sense , therefore PHP In the single instance mode, I think it's very meaningful to share the same object resource when multiple application scenarios occur in a single page level request .

Three key points of single case mode :

(1). A static member variable is required to hold a unique instance of the class :

private static $_instance;

(2). Constructors and clone functions must be declared private , Prevent external procedures new Class to lose the meaning of singleton pattern :

private function __construct()

{

$this->_db = pg_connect('xxxx');

}

private function __clone()

{

}// Cover __clone() Method , Prohibition of cloning

(3). You must provide a public static method to access this instance ( Usually it is getInstance Method ), To return a reference to a unique instance

public static function getInstance()

{

if(! (self::$_instance instanceof self) )

{

self::$_instance = new self();

}

return self::$_instance;

}

Implement singleton mode

class Singleton

{

// Create a static private variable to hold this class of objects

static private $instance;

// Prevent the use of new Create objects directly

private function __construct(){}

// Prevent the use of clone Clone objects

private function __clone(){}

static public function getInstance()

{

// Judge $instance Whether it is Singleton The object of , If not, create

if (!self::$instance instanceof self) {

self::$instance = new self();

}

return self::$instance;

}

public function test()

{

echo " I'm a singleton model ";

}

}

$sing = Singleton::getInstance();

$sing->test();

$sing2 = new Singleton(); //Fatal error: Uncaught Error: Call to private Singleton::__construct() from invalid context in

$sing3 = clone $sing; //Fatal error: Uncaught Error: Call to private Singleton::__clone() from context

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值