PHP面试题集锦

Jun 13, 2016 pm 12:28 PM
nbsp php

PHP面试题汇总

1、用PHP打印出前一天的时间格式是2014-01-13 12:10:21(2分)

  2、echo(),print(),print_r()的区别(3分)

  3、能够使HTML和PHP分离开使用的模板(1分)

  4、使用哪些工具进行版本控制?(1分)

  5、如何实现字符串翻转?(3分)

  —————————————————————

  6、优化MYSQL数据库的方法。(4分,多写多得)

  7、PHP的意思(送1分)

  8、MYSQL取得当前时间的函数是?,格式化日期的函数是(2分)

  9、实现中文字串截取无乱码的方法。(3分)

  —————————————————————

  10、您是否用过版本控制软件? 如果有您用的版本控制软件的名字是?(1分)

  11、您是否用过模板引擎? 如果有您用的模板引擎的名字是?(1分)

  12、请简单阐述您最得意的开发之作(4分)

  13、对于大流量的网站,您采用什么样的方法来解决访问量问题?(4分)

  —————————————————————–

  14、用PHP写出显示客户端IP与服务器IP的代码1分)

  15、语句include和require的区别是什么?为避免多次包含同一文件,可用(?)语句代替它们? (2分)

  16、如何修改SESSION的生存时间(1分).

  17、有一个网页地址, 比如柯乐义主页: http://keleyi.net/default.htm,如何得到它的内容?($1分)

  18、在HTTP 1.0中,状态码401的含义是(?);如果返回“找不到文件”的提示,则可用 header 函数,其语句为(?);(2分)

  19、在PHP中,heredoc是一种特殊的字符串,它的结束标志必须?(1分)

  20、谈谈asp,php,jsp的优缺点(1分)

  21、谈谈对mvc的认识(1分)

  ——————————————————————-

  22、写出发贴数最多的十个人名字的SQL,利用下表:members(id,username,posts,pass,email)(2分)

  23. 请说明php中传值与传引用的区别。什么时候传值什么时候传引用?(2分)

  24. 在PHP中error_reporting这个函数有什么作用? (1分)

  25. 请写一个函数验证电子邮件的格式是否正确 (2分)

  26. 简述如何得到当前执行脚本路径,包括所得到参数。(2分)

  27.如何修改SESSION的生存时间. (1分)

  ——————————————————————–

  28、JS表单弹出对话框函数是?获得输入焦点函数是? (2分)

  29、JS的转向函数是?怎么引入一个外部JS文件?(2分)

  30、foo()[email protected]()之间有什么区别?(1分)

  31、如何声明一个名为”myclass”的没有方法和属性的类? (1分)

  32、如何实例化一个名为”myclass”的对象?(1分)

  33、你如何访问和设置一个类的属性? (2分)

  34、mysql_fetch_row() 和mysql_fetch_array之间有什么区别? (1分)

  ——————————————————————–

  35、GD库是做什么用的? (1分)

  36、指出一些在PHP输入一段HTML代码的办法。(1分)

  37、下面哪个函数可以打开一个文件,以对文件进行读和写操作?(1分) 
  (a) fget() (b) file_open() (c) fopen() (d) open_file()

  38、下面哪个选项没有将 john 添加到users 数组中? (1分) 
  (a) $users[] = ‘john’; 
  (b) array_add($users,’john’); 
  (c) array_push($users,‘john’); 
  (d) $users ||= ‘john’;

  39、下面的程序会输入是否?(1分) 
  $num = 10; 
  function multiply(){ 
  $num = $num * 10; 
  } 
  multiply(); 
  echo $num; 
  ?>

  40、使用php写一段简单查询,查出所有姓名为“张三”的内容并打印出来 (2分) 
  表名 UserName Tel Content Date 
     张三 13333663366 大专毕业 2006-10-11 
     张三 13612312331 本科毕业 2006-10-15 
     张四 021-55665566 中专毕业 2006-10-15 
  请根据上面的题目完成代码: 
  $mysql_db=mysql_connect(“local”,“root”,“pass”); 
[email protected]_select_db(“DB”,$mysql_db);

  41、如何使用下面的类,并解释下面什么意思?(3) 
  class test{ 
  function Get_test($num){ 
  $num=md5(md5($num).“En”); 
  return $num; 
  } 
  }

  —————————————————————————-

  42、写出 SQL语句的格式 : 插入 ,更新 ,删除 (4分) 
  表名 UserName Tel Content Date 
     张三 13333663366 大专毕业 2006-10-11 
     张三 13612312331 本科毕业 2006-10-15 
     张四 021-55665566 中专毕业 2006-10-15 
  (a) 有一新记录(小王 13254748547 高中毕业 2007-05-06)请用SQL语句新增至表中 
  (b) 请用sql语句把张三的时间更新成为当前系统时间 
  (c) 请写出删除名为张四的全部记录

  43、请写出数据类型(int char varchar datetime text)的意思; 请问varchar和char有什么区别(2分)

  44、MySQ自增类型(通常为表ID字段)必需将其设为(?)字段(1分)

  45、写出以下程序的输出结果 (1分) 
  $b=201; 
  $c=40; 
  $a=$b>$c?4:5; 
  echo $a; 
  ?>

  46、检测一个变量是否有设置的函数是否?是否为空的函数是?(2分)

  —————————————————————————–

  47、取得查询结果集总数的函数是?(1分)

  48、$arr = array('james', 'tom', 'symfony'); 请打印出第一个元素的值 (1分)

  49、请将41题的数组的值用','号分隔并合并成字串输出(1分)

  50、$a = 'abcdef'; 请取出$a的值并打印出第一个字母(1分)

  51、PHP可以和sql server/oracle等数据库连接吗?(1分)

  52、请写出PHP5权限控制修饰符(3分)

  53、请写出php5的构造函数和析构函数(2分)

  ——————————————————————————

  54、以下请用PHPMYADMIN完成

  (一)创建新闻发布系统,表名为message有如下字段 (3分) 
  id 文章id 
  title 文章标题 
  content 文章内容 
  category_id 文章分类id 
  hits 点击量

  (二)同样上述新闻发布系统:表comment记录用户回复内容,字段如下 (4分) 
  comment_id 回复id 
  id 文章id,关联message表中的id 
  comment_content 回复内容 
  现通过查询数据库需要得到以下格式的文章标题列表,并按照回复数量排序,回复最高的排在最前面 
  文章id 文章标题 点击量 回复数量 
  用一个SQL语句完成上述查询,如果文章没有回复则回复数量显示为0

  (三)上述内容管理系统,表category保存分类信息,字段如下 (3分) 
  category_id int(4) not null auto_increment; 
  categroy_name varchar(40) not null; 
  用户输入文章时,通过选择下拉菜单选定文章分类 
  写出如何实现这个下拉菜单

  填空题

  1.在PHP中,当前脚本的名称(不包括路径和查询字符串)记录在预定义变量中;而链接到当前页面的URL记录在预定义变量中。

  2.执行程序段将输出。

  3.在HTTP 1.0中,状态码 401 的含义是;如果返回“找不到文件”的提示,则可用 header 函数,其语句为。

  4.数组函数 arsort 的作用是;语句 error_reporting(2047)的作用是。

  5.PEAR中的数据库连接字符串格式是。

  6.写出一个正则表达式,过虑网页上的所有JS/VBS脚本(即把scrīpt标记及其内容都去掉):。

  7.以Apache模块的方式安装PHP,在文件http.conf中首先要用语句动态装载PHP模块,然后再用语句使得Apache把所有扩展名为php的文件都作为PHP脚本处理。

  8.语句 include 和 require 都能把另外一个文件包含到当前文件中,它们的区别是;为了避免多次包含同一文件,可以用语句来代替它们。

  9.类的属性可以序列化后保存到 session 中,从而以后可以恢复整个类,这要用到的函数是。

  10.一个函数的参数不能是对变量的引用,除非在php.ini中把设为on.

  11.SQL中LEFT JOIN的含义是。如果tbl_user记录了学生的姓名(name)和学号(ID),tbl_score记录了学生(有的学生考试以后被开除了,没有其记录)的学号(ID)和考试成绩(score)以及考试科目(subject),要想打印出各个学生姓名及对应的的各科总成绩,则可以用SQL语句。

  12.在PHP中,heredoc是一种特殊的字符串,它的结束标志必须。

  编程题

   
  1. 写一个函数,尽可能高效的,从一个标准 url 里取出文件的扩展名 
  例如: http://keleyi.com/a/bjac/4w0otu4n.htm 需要取出 htm 或 .htm

  2. 在 HTML 语言中,页面头部的 meta 标记可以用来输出文件的编码格式,以下是一个标准的 meta 语句 
  请使用 PHP 语言写一个函数,把一个标准 HTML 页面中的类似 meta 标记中的 charset 部分值改为 big5 
  请注意: 
  1. 需要处理完整的 html 页面,即不光此 meta 语句 
  2. 忽略大小写 
  3. ' 和 " 在此处是可以互换的 
  4. 'Content-Type' 两侧的引号是可以忽略的,但 'text/html; charset=gbk' 两侧的不行 
  5. 注意处理多余空格

  3. 写一个函数,算出两个文件的相对路径 
  如 $a = '/a/b/c/d/e.php'; 
  $b = '/a/b/12/34/c.php'; 
  计算出 $b 相对于 $a 的相对路径应该是 ../../c/d将()添上

      写一个函数,能够遍历一个文件夹下的所有文件和子文件夹。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

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,

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

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

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

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

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

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.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

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.

See all articles