This article mainly shares with you a summary of PHP-related issues, mainly the problems we usually encounter. I hope it can help everyone.
1. Talk about your understanding of JavaScript closures?
Simply put, it is the application of scope: local variables and global variables.
Variables defined inside the function cannot be accessed outside the function, so the function is said to constitute a closure.
2. How to solve the AJAX cross-domain calling problem?
Two methods: 1. Server side:Use the Access-Control-Allow-Origin header on the request page
header("Access-Control-Allow-Origin: http://www.abc.com"); //允许指定网站 header("Access-Control-Allow-Origin: *");//允许所有网站 2.jsonp
<script type="text/javascript"> $.ajax({ dataType: "jsonp", url: "http://www.b.com/b.php", jsonp: "callback", success: function(data) { $(".info").text("uid:" + data.uid + " name:" + data.name); } }); </script> ajax.php文件: <?php $callback = !empty($_GET['callback']) ? trim($_GET['callback']) : ''; if(!empty($callback)) { $data = json_encode(array( 'uid' => 1, 'name' => '测试', )); echo "{$callback}({$data});"; }
Asynchronous: When this AJAX code is running, other codes can also run. Synchronization: Wait for this ajax code to finish running before executing other functions. Set by async:false parameter, default true (asynchronous).
4. Talk about your understanding of MVC?M(Model): Business rules for data V(View): The interface that users see and interact with C(Controller): Receive user data and call models and views to complete user needs.
The model sends the functions to be implemented to the controller, and the controller receives the organizational functions and passes them to the view;
5. How to understand Single entrance and multiple entrances?
Single entrance: All requests of the web program are directed to a script file. Multiple entries: Complete user requests by accessing different files.
Related recommendations:Concurrency - PHP questions for newbies
The above is the detailed content of Summary of php related issues. For more information, please follow other related articles on the PHP Chinese website!