Home > Backend Development > PHP Tutorial > PHP entry-level interview questions: Programming questions (2)

PHP entry-level interview questions: Programming questions (2)

韦小宝
Release: 2023-03-17 15:44:02
Original
1958 people have browsed it


Title

PHP entry-level interview questions are for programmers with little experience who are just looking for a job. This will be helpful to us The interview provided a lot of help. The interviewer officer would often test us, and the interview questions played a big role at this time.

5. Use PHP to print out the time of the previous day, in a format such as 2006-5-10 22:21:21

strftime(“%Y-%m-%d %T”, strtotime(“-1 day”));
date(“Y-m-d H:i:s”, strtotime(“-1 day”));
Copy after login

Just 1 correct answer

#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);
    }
}
Copy after login

7. Linux creates the file exer1 and sets the access permission to rw-r--r--. Now To increase the execution permissions of all users and the write permissions of users in the same group, write the command

touch exer1
chmod 644  exer1
增加权限
chmod a+x  exer1
chmod g+w  exer1
或者
chmod 775 exer1
Copy after login

8, string "to upper case" uses php, shell, and js respectively to convert all the characters in the string into uppercase and output them.

Php实现: echo strtoupper(‘to upper case’)
Copy after login
Shell实现:echo "to upper case" | tr 'a-z' 'A-Z'
Copy after login

Js implementation:

<script language="javascript">
var stmp1 = " to upper case ";
alert(stmp1.toLocaleUpperCase());//转换成大写
alert(stmp1.toUpperCase())//转换成大写
</script>
Copy after login

##9. Use Root login mysql database, if mydb does not exist, Create database mydb in mysql, Assign all permissions to the root user from 192.168 .1.1 ip to access the mysdb database. (The root user password is empty)

CREATE DATABASE IF NOT EXISTS mydb;
grant all on mydb.* to root@’ 192.168.1.1’ identified by &#39;&#39; ;
Copy after login

10. Now you need to get a list in the following format by querying the database, and sort it by the number of replies. The one with the highest reply is ranked Please write the sql for the first "Article ID Article Title Clicks and Replies":

## The message field of Table 1 is as follows:

Id自increment idContent ##category_idHitsTitleThe fields in Table 2 are as follows comment

Content

Category id

Clicks

Title

comment_idIdcomment_content
SELECT
M.`id`, M.`title`, M.`hits`, COUNT(C.`comment_id`) AS CNT
FROM
    `message` AS M LEFT JOIN `comment` AS C ON M.`id` = C.`id`
GROUP BY M.`id`
ORDER BY CNT DESC;
Copy after login
Don’t worry after reading the above interview questions, there are other interview questions, basic things It's best to consolidate them all to help us interview and find jobs.

Related recommendations:

php Junior Interview Questions Programming Questions (1)

php Junior Interview Questions Brief Description Questions (5)

php Junior Interview Questions Brief Description Questions (4)

The above is the detailed content of PHP entry-level interview questions: Programming questions (2). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template

reply id

The id in the associated message table

Reply content