A naxin test in a campus laboratory--(2) My service-side development pen test

Source: Internet
Author: User

Evening Finishing

A naxin problem of a campus laboratory--(1) Resource collation http://www.cnblogs.com/corvoh/p/4869403.html

The service side develops the pen question

1. Describe the difference between const and define.

When defining constants in PHP, the difference between const and define is:

Using const makes the code easy to read, and const itself is a language structure, and define is a function. In addition the const at compile time

Much faster than define. After PHP 5.3.0, you can use the Const keyword to define constants outside of the class definition, previous versions of Const

Keywords can only be used in classes (Class). Once a constant is defined, it can no longer be changed or undefined.

(1) The definition of const for a class member variable cannot be modified once it is defined. Define is not available for definitions of non-class member variables and can be used for full

The local constant.

(2) const cannot define a constant in a conditional statement.

Such as:

        if (... {          const FOOT = ' ball ';   Invalid definition         }        if (...). {          const FOOT = ' ball ';   Invalid definition         }

(3) const uses an ordinary variable name, and define can use an expression as its name.

Such as:

        Const FOOT  = ' Ball ';          for ($i = 0; $i < 32; + +$i)          {define$i$i);        }

(4) const can only accept static scalars, and define may take any expression.

Such as:

Const BIT_5 = 1 << 5; Invalid definition

Define (' Bit_5 ', 1 << 5); Valid definition

(5) const-defined constants are case-sensitive, whereas define can be referred to by the third argument (true for case insensitivity)

is sensitive to case sensitivity.

Such as:

        Define (' FOOT ', ' Ball ',true);         Echo //  Ball        Echo //  Ball

2. Explain the difference between the value of the function and the pass-through reference.

Pass by value: Any changes to the system within the scope of the function are ignored outside the function.

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

Advantages and Disadvantages

When passing by value, PHP must copy the value. This is a costly operation, especially for large strings and objects.

Passing by reference does not require copying values, which is good for performance gains.

If you do not want to change the value of the original variable, the value is passed, such as:

      <? PHP         $a = 1;         function aa ($a) {        echo + +$a;        }        AA ($a);      ? >

If you can let the function change the value of the original variable, you can refer to the value:

      <? PHP         $a = 9;         function aa (&$a) {        echo + +$a;        }        AA ($a);      ? >

3. Write at least two methods that do not use intermediate values to exchange values for a and B. (A and B All-small integer).

①a=a+b;b=a-b;a=a-b

②a=a*b;b=a/b;a=a/b

    <? PHP       $a = 1;       $b = 2;       $a $a+$b;       $b $a-$b;       $a $a-$b;       Echo $a ;    ? >

4. "Database" selects the SQL statement from the user in the table name field containing all the information for the first 10 results of admin.

  Select *  from User where  like ' %admin% ' 0,ten

5. Briefly describe the methods for the request of Get, POST, PUT, Helete, head in the HTTP protocol.

HEAD: Ask the server for a response that is consistent with the GET request, except that the response body will not be returned. This method allows you to obtain meta information contained in the response message header without having to transmit the entire response content.

GET: A request is made to a specific resource. The Get method should not be used in operations that produce "side effects."

POST: Submits data to the specified resource for processing requests (such as submitting a form or uploading a file). The data is included in the request weight. POST request

May result in the creation of new resources and/or modification of existing resources.

PUT: Uploads its latest content to the specified resource location.

The delete request server deletes the resource identified by the Request-uri.

6. Briefly describe the meaning of 1**, 2**, 3**, 4**, 5** in the HTTP request status code.

1**: Information class that indicates receipt of a Web browser request and is being processed further.

2**: The request was successful, indicating that the user request was successfully received, understood, and accepted by the server.

3**: Redirect indicates that the request did not succeed the client must take further action.

4**: Client error, indicating that the client submitted a request with an error.

5**: Server error, indicating that the server has an error or an abnormal state occurred while processing the request.

7. Describe the current method of resolving HTTP stateless using the service-side language?

HTTP itself is a stateless connection protocol, in order to support the interaction between the client and server, we need to use different technologies for the interactive storage state, and these different technologies are the cookie and session:

A cookie is a solution that maintains state through the client. A cookie is a special message that the server sends to the client. With the implementation of a technology such as cookies, when the server receives the request from the client browser, it can obtain the client-specific information by analyzing the cookie stored in the request header, and dynamically generate the corresponding content.

Session remains state through the server. A session is a server-side storage space for the client, where the information stored is used to hold the state. After the session is established on the server side, the client and server are contacted by the session ID, so that the user's State can be maintained.

example, the establishment and use of the session under the CodeIgniter framework.

Session on the server side of the establishment and use:

      $this->session->set_userdata (' user ',$user);? >      $user$this->session->userdata (' user '); >

8. Talk about your understanding of MVC.

MVC is the abbreviation of the model-view-controller. It is a mandatory input to the application,

Process and output a separate design pattern. 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.

The advantages of MVC: Low coupling, high reusability and applicability, low life cycle cost, rapid deployment, maintainability, extensibility, and benefit of software engineering management.

The drawbacks of MVC: there is no clear definition, and it is not easy to fully understand MVC, it is not suitable for small-scale applications, overly tight connections between views and controllers, inefficient access to model data, and so on.

9. Describe the most impressive issues you have encountered in the development process and the process of solving them.

The problem of communication in CI framework.

Summer vacation just contact PHP and CI, then have to do a user login and receive the user's own welcome interface ideas, need to use the transfer parameters.

Expected function: After registering, logging in and perfecting the information, the top left corner of the webpage outputs the user name + greeting.

The initial use of the arguments in the class method, when assigning views in a method, merges the parameters to create an array and save it to the $data to pass to the viewport.

Diagram, and then called in the view. But with the deepening of the Web page level, jump to the parameter becomes both difficult and repetitive difficult to change, in order to optimize the source code, then

To understand and revise and begin to find solutions.

The process of solving the problem depends on the user manual, Baidu Encyclopedia and other bloggers, find the key to learn to know the session.

When using the session to redeploy the source code, save a lot of space, also make the source code becomes clear and easy to understand, optimize a lot.

End up with a message to save this experience. The mini-website project attached below is the result of this experience.

Attached:

Personal blog: http://www.cnblogs.com/corvoh/

Personal homepage: http://hanyile.sinaapp.com/

A mini-site project: http://2.corvoh.sinaapp.com/

A naxin test in a campus laboratory--(2) My service-side development pen test

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.