PHP基础问题
1、用PHP打印出前一天的时间式是2013-04-2222:21:21 echo date('Y-m-d H:i:s', strtotime('-1 day')); 2、echo(),print(),print_r()的区别 echo和print都能输出字符串,但没有返回,print能够输出式化的字符串而print_r通常用于打印变量的相关信息,如数组
1、用PHP打印出前一天的时间格式是2013-04-2222:21:21
echo date('Y-m-d H:i:s', strtotime('-1 day'));
2、echo(),print(),print_r()的区别
echo和print都能输出字符串,但没有返回值,print能够输出格式化的字符串而print_r通常用于打印变量的相关信息,如数组
3、实现字符串的反转
strrev()
4、优化MYSQL数据库的方法
1)对索引进行优化
2)通过慢查询日志
3)定位SQL查询
5、用PHP写出显示客户端IP与服务器IP的代码
echo $_SERVER['REMOTE_ADDR'];
echo $_SERVER['SERVER_ADDR'];
6、语句include和require的区别是射门?为避免多次包含同一文件,可以使用什么代替?
include和require都是只包含文档,但require会产生致命错误而include只产生警告,可以使用require_once和include_once来代替
7、如何修改SESSION的生存时间
通过session_set_cookie_params('3600');
8、有一个网页地址,比如百度:http://www.baidu.com如何得到它的内容
$context = stream_context_create(array(
'http' => array(
'timeout' => 1 // 设置一个超时时间,单位为秒
)
));
file_get_content('http://www.baidu.com');
9、在HTTP1.0中,状态码401的含义是未收授权,如果返回“找不到文件”的提示,则可用header函数,其语句header('HTTP1.0 404 Not Found')
10、在PHP中,heredoc是一种特殊的字符串,它的结束标志必须?
结束标志不能包含其他任何字符除了';'
11、说明PHP中传值和传引用的区别,什么时候传值什么时候传引用?
函数内对传送变量修改不影响被传变量的值(用传值对函数内的变量重新赋值);
传送变量的引用,函数内的任何操作等同于对传送变量的操作,传送大型变量时效率高
12、在PHP中error_reporting函数的作用是什么?
设置报错级别
error_reporting(0); // 禁用错误报告
error_reporting(E_ERROR|E_WARNING|E_PARSE); // 报告运行时错误
error_reporting(E_ALL); // 报告所有错误
13、JS的转向函数是?怎么引入一个外部JS文件?
location.href
14、foo()和@foo()之间有什么区别?
@foo()控制错误输出
15、mysql_fetch_row()和mysql_fetch_array()之间有什么区别?
两个函数都返回一个数组,不同点在于前者返回只包含值,后者返回包含键值对
16、检测一个变量是否有设置的函数是?是否为空的函数是?
isset() empty()
17、写一个函数,能够遍历一个文件夹下的所有文件盒子文件夹。
function scan_directory($dir) {
$result = array();
$cdir = scandir($dir);
foreach ($cdir as $key =>$value) {
if(!in_array($value, array('.', '..'))) {
if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
$result[$value] = scan_directory($dir . DIRECTORY_SEPARATOR .$value);
}else {
$result[] = $value;
}
}
}
return $result;
}
print_r(scan_directory(dirname(__FILE__)));
18、utf-8和gbk区别
utf-8是国际编码,通用性较强,英文采用单字节编码中文采用三字节编码。而gbk是国家标准编码,采用双字节编码
19、MySQL的存储引擎MyISAM与InnoDB有什么区别
1)、两者在文件构成上有区别;
2)、InnoDB支持事务处理,MyISAM不支持;
3)、锁的区别:InnoDB支持表级锁和行级锁,MyISAM只支持表级锁。
二 PHP试题(2)
1、随便说出3个php处理数组的内置函数,如果说不出可以说说思路
例如:array_merge array_keysarray_diff array_values
2、怎么判断两个数组相等
我的理解应该是键值都相等
3、你熟悉的PHP框架有哪些?
4、get_magic_quotes_gpc()的作用是什么(新浪试题)
5、其中有问到对MongoDB的底层有过了解没?说说你对Redis的理解?以及Redis有哪些场景应用,并分别就一两种场景说说使用到哪些redis的相关知识?
三NodeJS试题
1、 '1' + 2 + 3
1 + 2 + '3'
上面的返回值是多少?
2、下面的返回值又是多少?
'hello world'.indexOf('hello');
['hello', 'world'].indexOf('hello');
{'hello': 'world'}.indexOf('hello');
3、以下自己平时印象比较深刻的整理的
以下返回
var str = 'xcsasds';
alert(str.slice(0, -3));
alert(str.substring(1, -3));
4、function add(x, y) {
return x + y;
}
var add;
// var add = 3; // 换成赋值的返回又是啥
alert(typeof add);
5、var test;
var str1 = new String(test);
var str2 = test.toString();
alert(str1);
alert(str2);
输出结果是什么?
6、以下输出结果?
var str = '25';
console.log(typeof str);
var str2 = +str;
console.log(typeof str2);

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











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,

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

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 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

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.
