The programming problem of PHP primary plane question (II.)

Source: Internet
Author: User
Title

PHP Junior Test is just looking for a job of inexperienced programmers to see, this to us out of the interview to provide a lot of help, the interviewer will often test us, and this time to see the face of the question has played a big role.

5. Use PHP to print out the day before, format for example 2006-5-10 22:21:21

Strftime ("%y-%m-%d%T", Strtotime ("1 day"));d ate ("y-m-d h:i:s", Strtotime ("-1 day"));

Answer 1 correctly

6. Write a function that can traverse all files and subfolders under a folder

function Dir_recurse ($dir) {    $i = 1;    if ($handle = Opendir ($dir)) {while        (false!== ($file = Readdir ($handle))) {            if ($file! =). "&& $file! =". ." ) {                if (Is_dir ($dir. ") /". $file) = = True) {                    $fullpath = $dir." /". $file;                    Dir_recurse ($fullpath);                    echo "$fullpath \ n";                    $i + +;                } else {                    $fullpath = $dir. " /". $file;                    echo "$fullpath \ n";                    $i + +                ;        }}} Closedir ($handle);    }}

7, Linux Create file Exer1, set access rights to rw-r--r--, now to increase the execution rights of all users and the same group of users write permissions, write out the operation of the process command

Touch Exer1chmod 644  exer1 Add permissions chmod a+x exer1chmod g+w  exer1 or chmod 775 exer1

8, the string "to upper case" respectively with the Php,shell, JS implementation of the characters in the string are all converted to uppercase and output.

PHP implementation: Echo Strtoupper (' to upper case ')
Shell implementation: echo "to upper case" | Tr ' A-Z ' A-Z

JS implementation:

<script language= "javascript" >var STMP1 = "to upper case"; Alert (Stmp1.tolocaleuppercase ());//Convert to uppercase alert ( Stmp1.touppercase ())//Convert to uppercase </script>

9. Log in to MySQL database with root, if MyDB does not exist, create database mydb in MySQL, Assign all permissions to the root user to access the MYSDB database from the 192.168.1.1 IP. (The root user password is empty)

CREATE DATABASE IF not EXISTS mydb;grant all on mydb.* to root@ ' 192.168.1.1 ' identified by ';

10, now by querying the database need to get a list of the following format, and in accordance with the number of replies, the highest ranking in the top "Article ID article title Click reply Quantity" please write sql:

Table 1 The Message field is as follows:

Id

Self-Increment ID

Content

Content

category_id

Category ID

Hits

Click Volume

Title

Title

Table 2 fields are as follows comment

comment_id

Reply ID

Id

ID in the associated message table

Comment_content

Reply content

SELECTM. ' id ', M. ' title ', M. ' Hits ', COUNT (C. ' comment_id ') as Cntfrom    ' message ' as M ' left JOIN ' comment ' as C on M. ' ID ' = C. ' id ' GROUP by M. ' ID ' ORDER by CNT DESC;

To read the above questions do not worry, there are other interview questions, the basis of the best things to consolidate a bit, help us to find a job interview.

Related recommendations:

The programming problem of PHP primary plane question (i.)

A brief discussion on the basic question of PHP (v)

A brief introduction to the basic question of PHP (iv)

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.