PHP interview needs to master the basic issues of the brocade set

Source: Internet
Author: User
Tags zend framework
PHP interview needs to master the basic topics of the Brocade set

What is the difference between 1.session and cookie ?

A : Session: Store user access to the global unique variable , stored in the server in the PHP specified directory (session_ Dir) Location of the store

Cookie: Used to store continuous access to a page, is stored on the client, and for cookies is stored in user WIN 's Temp in the directory.

Both can be set time by time

2. How to modify the SESSION Lifetime

Answer : method 1: set session.gc_maxlifetime in php.ini to 9999 restart Apache

Method 2: $savePath = "./session_save_dir/";

$lifeTime = Hour * second ;

Session_save_path ($savePath);

Session_set_cookie_params ($lifeTime);

Session_Start ();

Method 3:setcookie () and Session_set_cookie_params ($lifeTime);

3. what is PHP?

A :P hp is a scripting language that creates dynamic Web sites based on the server, and you can generate Web pages with PHP and HTML

4. Statements include and the require What's the difference? ? to avoid containing the same file multiple times, you can (?) statements instead of them ? (2 points )

A : Require->require is an unconditional inclusion, that is, if a process to add require, whether or not the condition will be executed first Require

Include->include has a return value, and require does not ( possibly because of this require faster than include )

Note : require is fatal when the include file does not exist or is syntactically incorrect , include is not

5. Talk asp,php,jsp the pros and cons

A : ASP full name Active server Pages, is a WEB Server-side development environment, using it can generate and transport

A: Line dynamic, interactive, high-performance WEB service applications. The ASP uses the scripting language VBscript(Java script

) as their own development language.

   PHP is a cross-platform, server-side, embedded scripting language . it borrows in large quantities C,java and the Perl Grammar of the language

, coupled with PHP 's own features , allowing WEB developers to quickly write dynamically generated pages . it supports the vast majority of current

Data base. Also,php is completely free of charge and you can get from the official php site (http://www.php.ne

t) free download. And you can gain unrestricted access to the source code, and even add the features you need.

   JSP is Sun 's New generation of site development language, he completely solved the current asp,php A common problem--

Script-level execution (the PHP4 is said to have been compiled and run with the support of Zend ). Sun Company with its own in Jav

an extraordinary accomplishment on a, java from java applications and Java applets , There is a new fruit, is Js

P--Java Server Page. Jsp can complete powerful sites with support from serverlet and JavaBean

Program.

   All three provide the ability to mix some kind of program code in HTML code, and the language engine to interpret the code of the Execution program.

However, the JSP code is compiled into a Servlet and interpreted by the Java virtual machine, which is done only in the case of JSP of the page

Occurs the first time the request is requested. In ASP ,PHP,JSP Environment, HTML The code is primarily responsible for describing the display style of information

, and the program code is used to describe the processing logic. Normal HTML pages depend only on Web servers, while ASP ,PH

P,JSP pages require additional language engine parsing and executing program code. The execution results of the program code are re-embedded in the

HTML Code, and then send it together to the browser. ASP ,PHP, JSP are Web Server- oriented technology

, the client browser does not require any additional software support.

5. Talk about the understanding of MVC, and list common frameworks?

A: MVC is a design pattern that makes it mandatory to separate the input, processing, and output of an application . Using an MVC application is divided into three core parts: model, view, controller. Each of them handles their own tasks.

A view is an interface that the user sees and interacts with.

Models represent enterprise data and business rules.

The controller accepts the user's input and invokes the model and view to complete the user's needs.

Benefits of MVC: Low coupling, high reusability and applicability, low life cycle costs, rapid deployment, maintainability, scalability, and benefits for software engineering Management

the downside of MVC: there's no clear definition, and it's not easy to fully understand MVC . Not suitable for small-scale applications.

Smarty,Zend Framework, thinkphp,phplib Template

6.php How do I throw an exception?

Answer: Use Try...catch, the code of the exception is placed inside the try block, and if no exception is triggered, the code continues execution and throws an exception if the exception is triggered.

The catch code block catches the exception and creates an object that contains the exception information. $e->getmessage (), output an error message for the exception.

7. What is the difference between a value and a reference in PHP?

A: Passing by value: Any changes to values within the function scope are ignored outside the function

Pass by reference: Any changes to values within a function can also reflect these changes outside of the function

Pros and Cons: When passing by value,PHP must copy the value. This can be a costly operation, especially for large strings and objects.
Passing by reference does not require copying values, which is good for performance gains.

What is the difference between include and require in 8,php?

A: PHP must be re-interpreted when it encounters the include , and it will be re-interpreted ten times If it appears on the same page. PHP When encountering require , no matter in the same PHP page appears several times require,PHP will only explain once.

Second, Require implementation efficiency than include high.

Third, Require contains the content is considered as a part of the current file, so when the included file has a syntax error or the file does not exist, the PHP script is no longer executed. the include function is equivalent to specifying the path to the file, which does not affect the execution of the program itself when the contained file is in error.

Iv. include can be judged whether it is included, and require is included in any case

9. What is the difference between get and post submission methods in a form ?

A : Get is a send request HTTP Protocol that is passed through the URL parameter to receive ,

Post is Entity Data , large amounts of information can be submitted through forms .

The difference betweenEcho (), print (), Print_r ( ) ( 3 points )

Answer : Echo is a PHP statement , print and print_r are functions , statement does not return a value , the function can have a return value ( Even if it is not used )

print() prints only the values of a simple type variable ( such as int,string)

print_r() can print out values for complex type variables (such as arrays , objects )

echo outputs one or more strings

What are the transactions in the database ?

A : a transaction (transaction) is an ordered set of database operations as a unit. If all operations in the group are successful, the transaction is considered successful and the transaction is unsuccessful even if only one operation fails. If all operations are completed,

The transaction is committed and its modifications are made to all other database processes. If an operation fails, the transaction is rolled back, and the effect of the firm's operations is canceled.

12. Server Apache two modes of operation and differences

Answer: 1.PREFORK.C module (a non-threaded, pre-derived MPM)
prefork MPM uses multiple child processes, with only one thread per child process. Each process can only maintain one connection at a certain time. On most platforms, the Prefork MPM is more efficient than the worker mpm , but the memory usage is much larger.
2. WORKER.C Module (multi-threading module supporting mixed multi-threaded multi-process)
The worker MPM uses multiple child processes, each of which has multiple threads.



  • Related Article

    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.