PHP初级面试题整理
今天看到一份PHP初级面试题给大家分享下,好像挺逗比的。其实自己也挺头疼面试的,老是搞那种理论。习惯百度谷歌的人,真想回答句自己百度去。
一、前端部分
Firefox和google浏览器使用的引擎是什么?(前段最起码最起码的基础,调流浏览器兼容性必知。也是使用CSS3和HTML5是必知)
Firefox 使用的是 Gecko,而 Safari 和 Chrome 浏览器使用的都是 Webkit。最新版的opera也使用了webkit
如何用CSS实现水平居中和垂直居中?(基础的基础)
水平居中:text-align:center;margin:0 auto
垂直居中:可以将容器设置为display:table,然后将子元素也就是要垂直居中显示的元素设置为display:table-cell,然后加上vertical-align:middle来实现。或者使用{top:50%;transform: translateY(-50%);}
以上都是不完美实现,但都是基础。根本没思路的是骗子。
如何处理jQuery冲突?(基础的基础)
jQuery.noConflict(); 或者用闭包
(function($){})(jQuery);
二、数据存储部分
怎样定位MySQL中效率较低的语句?
使用show full processlist和慢查询日志。
数据库的增量备份主从服务做过没?
关键点在binlog,也就是二进制日志。
MYISAM引擎和INNODB引擎的对比?
关键点:表锁行锁,是否支持事务,索引的存储,适用场景
如果面试者简历中提到了熟悉memcache,那么就问:memcache的默认端口是啥?Value的最大长度是啥?默认的缓存有效期是多久?
答案:端口:11211 ,value最大1M,有效期30天。这三个问题有两个回答错的就是骗子。
如果提到redis,就问redis的最大value值是多少?存储有序和无序集合用哪种数据类型?哪个命令发起事务?哪两种持久化方式?
答案:value最大512M,有序用list和sorted set,无序用 set;发起事务用multi;持久化方式为内存快照和日志追加。
PHP部分:
类的自动加载怎么实现?
spl_autoload_register,回答__autoload 的是没做过,人云亦云的瞎扯。
列举几个PHP的魔术方法?
__set(),__get(),__construct(),__call(),__toString()。一共有14,5个,回答不出4个的说熟悉面向对象是在瞎扯。
正则表达式只能怪不区分大小写的修饰符是哪个?不用正则如何判断email格式是否正确?
答案:i;使用filter系列函数,如果能输出这个系列函数的缺陷更佳。
4.MVC的基本流程,每层都干些什么?自己是否实现过MVC框架?
服务器及其它
linux中类似win的资源管理器命令是哪个?怎样查看开机自启动有哪些服务?计划任务是哪个服务实现?删除非空文件夹用什么命令?
答案:top;chkconfig –list;crontab;rm -r;
平常经常去的技术社区。
再附一款
* 1.在PHP中,当前脚本的名称(不包括路径和查询字符串)记录在预定义变量(1)中;而链接到当前页面的URL记录在预定义变量(2)中。
2.执行程序段将输出(3)。
3.在HTTP 1.0中,状态码 401 的含义是(4);如果返回“找不到文件”的提示,则可用 header 函数,其语句为(5)。
4.数组函数 arsort 的作用是(6);语句 error_reporting(2047)的作用是(7)。
5.PEAR中的数据库连接字符串格式是(8)。
6.写出一个正则表达式,过虑网页上的所有JS/VBS脚本(即把script标记及其内容都去掉):(9)。
7.以Apache模块的方式安装PHP,在文件http.conf中首先要用语句(10)动态装载PHP模块,
然后再用语句(11)使得Apache把所有扩展名为php的文件都作为PHP脚本处理。
8.语句 include 和 require 都能把另外一个文件包含到当前文件中,它们的区别是(12);为了避免多次包含同一文件,可以用语句(13)来代替它们。
9.类的属性可以序列化后保存到 session 中,从而以后可以恢复整个类,这要用到的函数是(14)。
10.一个函数的参数不能是对变量的引用,除非在php.ini中把(15)设为on.
11.SQL 中LEFT JOIN的含义是(16)。
如果 tbl_user记录了学生的姓名(name)和学号(ID),
tbl_score记录了学生(有的学生考试以后被开除了,没有其记录)的学号(ID)和考试成绩(score)以及考试科目(subject),
要想打印出各个学生姓名及对应的的各科总成绩,则可以用SQL语句(17)。
12.在PHP中,heredoc是一种特殊的字符串,它的结束标志必须(18)。
13.写一个函数,能够遍历一个文件夹下的所有文件和子文件夹。
14.简述论坛中无限分类的实现原理。
15.设计一个网页,使得打开它时弹出一个全屏的窗口,该窗口中有一个文本框和一个按钮。用户在文本框中输入信息后点击按钮就可以把窗口关闭,而输入的信息却在主网页中显示。
//答案(填空):
1. echo $_SERVER['PHP_SELF']; echo $_SERVER["HTTP_REFERER"];
2. 0
3. (4)未授权 (5) header("HTTP/1.0 404 Not Found");
4. (6)对数组进行逆向排序并保持索引关系 (7)All errors and warnings
5. 没弄明白
6. /<script>].*?>.*?</script>/si
7.(10) LoadModule php5_module "D:/xampp/apache/bin/php5apache2.dll"
(11) AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml
8.(12) 发生异常时include产生警告require产生致命错误 (13) require_once()/include_once()
9. serialize() /unserialize()
10. allow_call_time_pass_reference
11. (16) 自然左外连接
(17) select name , count(score) as sum_score from tbl_user left join tbl_score on tbl_user.ID=tbl_score.ID group by tbl_user.ID
12. 结束标识符所在的行不能包含任何其它字符除";"
13.
/**
* 遍历目录,结果存入数组。支持php4及以上。php5以后可用scandir()函数代替while循环。
* @param string $dir
* @return array
*/
function my_scandir($dir)
{
$files = array();
if ( $handle = opendir($dir) ) {
while ( ($file = readdir($handle)) !== false ) {
if ( $file != ".." && $file != "." ) {
if ( is_dir($dir . "/" . $file) ) {
$files[$file] = rec_scandir($dir . "/" . $file);
}else {
$files[] = $file;
}
}
}
closedir($handle);
return $files;
}
}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7
