2018.7.19. PHP Review

Source: Internet
Author: User
Tags html form php programming

PHP programming 1. Please write out the full English word for HTML tag meta: Metadata2. The property of the meta tag that corresponds to the function of the HTTP file header (the message that returns the Web page content correctly and accurately to the browser) is http-equiv3.php: Php:hypertext The two modes of operation of preprocessor4.php are CGI and MOD_PHP5. Running PHP in mod_php mode, why does the configuration need to restart Apache every time the configuration information is changed for php.ini?
6. What is the Echo feature in PHP?
将PHP后台运行得到饿数据输出到浏览器页面中
7. Differences in output
$"加油";则(1)echo ‘中国$str!‘;  输出中国$str!          (2)echo "中国$str!" ;输出   中国加油!
8. When other types of variables are converted to Boolean types, what values are considered false?
布尔值false,整形值0,浮点值0.0,空白字符串,字符串‘0‘,空数组,特殊数据类型NULL,没有设定的变量。
9. In the browser run the following PHP code, in three text boxes, respectively, enter 1, 2, 3, then the browser page output sparkqty32110. and C, in the PHP function to access the declaration of the global variables outside the function, must be at the beginning of the function with Golbal declaration 11. What are some of the predefined variables (magic variables) commonly used in PHP?
$_post  $_get   $_request   $_session  $_cookie  $_files  $_SERVER  $GLOBALS
What are some of the predefined constants (magic variables) commonly used in PHP?
 _line_  _file_  _dir_  _function_    _class_  _traint_  _method_  _namespace_  
13. What is the concept of arrays? The data is divided into the two types according to the index, how to distinguish? What are the two main ways to declare an array?
数组是一个可以存储一组或一系列数值的变量(复合型变量);索引数组(索引值为数字,以0开始)和关联数组(以字符串作为索引值);(3)数组的声明方式主要用两种:A 通过array() 函数声明数组,可以通过key=>value 的方式分别定义索引和值,也可以不定义数组的索引下标,只给出数组的元素值。B直接为元素赋值,不需要调用array()  函数。例如:$arr[0]=1,$arr[1]=2;
14. Array merging functions Array_merge () and arrays addition operations $arr1+ What is the difference between $arr 2
    1. Array Merge function Array_merge () and arrays addition operations $ARR1 + $arr 2 What is the difference? The
      uses Array_merge (), and if the associative array is merged, if the array has the same key name, then the subsequent value overrides the former, and if it is a numeric indexed array merge, it is not overwritten, but the latter is appended to the former. Using array addition, unlike Array_merge (), an addition operation, whether an associative or a numeric index array, discards the value of the same key name, preserving only the first occurrence of the key name, and subsequent elements with the same key name are not added.
    2. Brief description of the array compact (mixed $varname [, mixed ...]) Functions of the function. The
      sets one or more variables into an array element whose key name is the variable name of the variable, and the value is the value of the variable.
    3. Briefly describes the method by which the PHP array is converted to strings and string conversions to arrays.
      Explode (String $separator, string $string [, int $limit]) separates a string with a delimiter character.
      Implode (string $glue, array $arr) uses a connector to concatenate each cell in the array into a string.

    4. The following message function code has a vulnerability to page tampering (XSS attack), please write a simple filtering method to prevent the page from tampering with the complete code.

      <?php
      $Email =$_post[' Email ';
      $note =$_post[' note '];
      echo "User". $Email. " Hello!  ";
      Echo
      Your message is:
          . $note.
      ";
      ?
    5. The regular expression for the
    6. Validate ID number rule is: #^[0-9]{17} ([0-9]| X| Y) $#.
    7. briefly describes the function of PHP function file_get_contents ().
      As with the functions of calling fopen (), fwrite (), and fclose () functions, the default is to overwrite the contents of the original file directly.
    8. What are the 3 criteria that must be met for an HTML form to generate file upload variables?

(1) must be submitted using post (set form method= "POST"), (2) The form must be set Enctype property is Enctype= "Multipart/form-data"; (3) A text field control should be in the form.

  1. The file upload variable is generated by the HTML form, and PHP logs the details of the uploaded file as an array, the predefined variable (global array) is the name of the ___$_files[' upload control ' [' Name ' | ' Type ' | ' Tmp_name ' | ' Size ' | ' Error '].
  2. Cookies run on the client, the session runs on the server side, right?
    Not exactly right. Cookies are run on the client side and managed by the client, although the session is run on the server, but SessionID as a cookie is stored on the client.
  3. is the Session safer than a cookie? Shouldn't a lot of cookies be used?
    Error. Cookies may indeed have some unsafe factors, but like JavaScript, the backend is secure even if the front-end verification is breached. So, everything depends on the design. If it is unsafe, it is also because the code is unsafe to mistakenly use the authenticated cookie as permission validation.
  4. If I copy a cookie from someone else's machine onto my computer (assuming the same browser is used), is it possible to log in to someone else's account?
    Yes. This is a practice of cookie hijacking.
  5. When using get value in the URL, if the Chinese garbled, which function should be used to encode Chinese?
    Use UrlEncode () to encode Chinese, using UrlDecode () to decode.
  6. A static member or function in the Access class in PHP should be accessed through the class name:: or self::.
  7. Inheritance is an important mechanism for code reuse, but inheritance destroys encapsulation, and inappropriate inheritance can violate real-world logic. PHP uses an updated code reuse mechanism, which combines objects in a consistent way, adding horizontal features, a mechanism that is PHP's traits mechanism.
  8. PHP does not currently support method overloading, but it is possible to use the Magic Method __ _call to implement functionality similar to method overloading.
  9. Relational mode: CJB (school number, course number, score), put SQL language: SELECT * from CJB a WHERE score < (select AVG (score) from CJB B where b. Course Number = A. Course number), translated into Chinese query test results The student's academic number, course number, and result of the average low grade of the course.
  10. What is the difference between mysql_fetch_row () and Mysql_fetch_assoc () and mysql_fetch_array ()?
    The first is to return a row in the result set as an indexed array (an array of key names is called an indexed array), the second is to return an associative array (at least one array of key names is a string called an indexed array), and the third can return an indexed array or an associative array, depending on its second parameter is Mysql_ BOTH or Mysql_num or MYSQL_ASSOC default to Mysql_both.
  11. The exec () method is a method of the PDO class, and the Execute () method is a method of the Pdostatement class.
  12. Describes what transaction processing is and how the PDO transaction is implemented in PHP.
    Transactions: Simplify error recovery and make your application more reliable by combining a set of related actions into a single unit that either succeeds or fails all. PDO transaction Implementation process: First define the parameters of the database connection, create a try{}catch{} statement, instantiate the PDO constructor in the try{} statement, complete the connection to the database, and open the transaction through the BeginTransaction () method It then writes the transaction-processing business logic code, completes the commit operation of the transaction through the commit () method, returns an error message in the catch{} statement, and performs a rollback operation of the transaction through rollback ().
  13. What is Ajax? What is the principle of Ajax? What is the core technology of Ajax? What are the pros and cons of Ajax?
    Ajax is the abbreviation for asynchronous JavaScript and XML, and is a combination of JavaScript, XML, CSS, Dom and many other technologies. Ajax works by specifying that the location of a page can load all the output from another page, thus enabling a static page to retrieve the returned data information in the database. So Ajax technology enables a static Web page to communicate with the server without refreshing the entire page, reducing user latency while reducing network traffic and enhancing the friendliness of the customer experience.
    The core technology of Ajax is XMLHttpRequest, which is an object in JavaScript. The advantages of Ajax are: (1) reduce the burden on the server, a part of the previous workload from the server to the client to execute, with the client idle resources for processing, (2) in the case of only partial Refresh update page, increase the page response speed, make the user experience more friendly. The disadvantage of Ajax is not conducive to SEO promotion optimization, because the search engine can not directly access the content of the AJAX request.

2018.7.19. PHP Review

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.