1.$array['anykey']和$array[anykey]的区别?
答:单引号和没有单引号区别,就是字符串和常量。而单引号和双引号的区别,就是字符串和变量吧。
不加单引号的话,php会首先认为他是常量,然后去搜寻是否存在这个常量,若不存在,则理解为字符串,所以在效率上就慢了。
2.echo 输出语句时候的连接符号: "." 和 ","。点号和逗号的区别?
答:echo用点号时先把语句连接再输出,而用逗号就等于给它传多个参数,不需要进行字符串拼接这一步,效率高! // 本文来自技术世界www.js4j.com 技术教程//
3.echo,print,print_r的区别?
答:echo,直接输出单个或者多个字符串,是PHP语句!
print,打印输出简单类型,是PHP函数!有整型返回值。我试验了下,都返回1。
print_r,格式化打印输出,常用于比较复杂的类型,如数组,对象之类的,可以输出完整结构,是PHP函数,返回值类型为布尔型!
4.获取前天的日期,格式如:2009-01-12 17:15:20
答:echo date('Y-m-d h:i:s',time()-2*24*60*60);
echo date('Y-m-d h:i:s',strtotime('2 days ago')); 未来几天的话把 ago 去掉就行了 // 来自www.js4j.com 技术BBS论坛//
5.如何将字符串翻转过来?
答:$str = '7654321';
echo strrev($str); //1234567
另一种方法:
$strlen = strlen($str);
for ($i = 1; $i echo substr($str,-$i,1);
} // 内容来自js4j.com//
6.优化MySQL数据库的方法?
答:①选取最适用的字段属性。
②是用连接(JOIN)来代替子查询(Sub-Queries)。
③是用联合(UNION)来代替手动创建的临时表。
④事务
⑤锁定表
⑥使用外键
⑦使用索引
⑧优化的查询语句
上面8条优化的详细说明请点击该链接查看完全优化MySQL数据库性能的八大巧方法
7.PHP的意思?(送一分)
答:Hypertext preprocessor 超文本预处理语言。(汗!我google了才知道滴。。送一分都得不到啊,撞墙!!)
8.MYSQL取得当前时间的函数是?格式化日期的函数是?
答:当前日期函数为 NOW();
格式化日期函数是:
SELECT DATE_FORMAT('2009-01-11 17:25:36',"%H:%i:%s %m/%d/%Y");
->17:25:36 01/11/2009
其它时间函数:详细请查看该页面 MySql 格式化时间函数
SELECT DAYOFWEEK('1998-02-03');
->3
SELECT WEEKDAY('1997-10-04 22:23:00');
->5
SELECT WEEKDAY('1997-11-05');
->2
SELECT DAYOFMONTH('1998-02-03');
->3
SELECT DAYOFYEAR('1998-02-03');
->34
SELECT MONTH('1998-02-03');
->2
SELECT DAYNAME('1998-02-05');
->'February'
SELECT QUARTER('1998-04-01');
->2
SELECT WEEK('1998-02-20');
->7
SELECT WEEK('1998-02-20',0);
->7
SELECT WEEK('1998-02-20',1);
->8
SELECT YEAR('98-02-03');
->1998
SELECT HOUR('10:05:03');
->10
SELECT MINUTE('98-02-03 10:05:03');
->5
SELECT SECOND('10:05:03');
->3
SELECT PERIOD_ADD(9801,2);
->199803
SELECT PERIOD_DIFF(9802,199703);
->11
SELECT TO_DAYS('1997-10-07');
->729669
SELECT TO_DAYS(950501);
->728779
SELECT FROM_DAYS(729669);
->'1997-10-07'
SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00');
->875996580
SELECT FROM_UNIXTIME(875996580);
->'1997-10-04 22:23:00'
SELECT SEC_TO_TIME(2378);
->00:39:38
SELECT TIME_TO_SEC('00:39:38');
->2378 // 本文来自技术世界www.js4j.com 技术教程//
9.怎样截取中文且不出现乱码?
答:如果安装了mb扩展可使用mb_substr();
可以使用以下函数:
function cutstr($sourcestr, $startlength, $cutlength)
{
$returnstr='';
$i=0;
$n=0;
$str_length=strlen($sourcestr); //字符串的字节数
while (($n {
$temp_str=substr($sourcestr,$i,1); // 内容来自js4j.com//
$ascnum=Ord($temp_str); //得到字符串中第$i位字符的ascii码
if ($ascnum>=224) { //如果ASCII位高与224,
$returnstr=$returnstr.substr($sourcestr,$i,3); //根据UTF-8编码规范,将3个连续的字符计为单个字符
$i=$i+3; //实际Byte计为3
$n++; //字串长度计1
} elseif ($ascnum>=192){ //如果ASCII位高与192,
$returnstr=$returnstr.substr($sourcestr,$i,2); //根据UTF-8编码规范,将2个连续的字符计为单个字符
$i=$i+2; //实际Byte计为2
$n++; //字串长度计1 // 来自www.js4j.com 技术BBS论坛//
} elseif ($ascnum>=65 && $ascnum $returnstr=$returnstr.substr($sourcestr,$i,1);
$i=$i+1; //实际的Byte数仍计1个
$n++; //但考虑整体美观,大写字母计成一个高位字符
} else { //其他情况下,包括小写字母和半角标点符号, // 内容来自技术世界www.js4j.com 技术爱好者//
$returnstr=$returnstr.substr($sourcestr,$i,1);
$i=$i+1; //实际的Byte数计1个
$n=$n+0.5; //小写字母和半角标点等与半个高位字符宽...
}
if ($n $returnstr = '';
continue;
}
}
if ($str_length>$cutlength){
$returnstr = $returnstr . "..."; //超过长度时在尾处加上省略号
}
return $returnstr;
}
10.对于大流量的网站,您采用什么样的方法来解决访问量问题?
答:①最根本的是服务器硬件条件。服务器硬件设备如果太差,那不管怎么优化都是徒劳!
②对数据库进行优化。主要是减少对数据库的访问量。访问过多会造成服务器CPU过度消耗,导致服务器受访能力严重下降,解决方法是是前台使用静态或者动态缓存!
③防盗链。对于Apache服务器,主要是是用model_rewrite 模块通过对URL的正则,进行限制和重定向!
④控制大文件下载。不提供超过2MB的文件下载,或使用专门的下载服务器,或者上传到web2.0共享网站上。
⑤多主机分流。将不同文件放置在不同的主机,提供镜像之类的文件下载方式。
⑥是用专业的流量分析软件。如google流量分析。对网站进行精细的流量控制!
11.用PHP写出显示客户端IP与服务器IP的代码? // 本文来自技术世界www.js4j.com 专业技术门户网站//
答:客户端IP获取 $_SERVER['REMOTE_ADDR'];
服务端IP获取 $_SERVER['SERVER_NAME'];
12.如何修改SESSION的生存时间?
答:$lifeTime = 24*3600;
session_set_cookie_params($lifeTime);
session_start();
详细的设置请查看这篇文章:PHP对session生存时间的设置详细介绍。
13.有一个网页地址, 比如PHP研究室主页: http://www.163fly.com/index.php如何得到它的内容?
答:$src = 'http://www.163fly.com/index.php';
$file = 'D:\index.html';
①$content = file_get_contents($src);
$hfile = fopen($file,w);
$result = fwrite($hfile,$content);
②$opsrc = fopen($src,r);
$wfile = fopen($file,w);
$result = stream_copy_to_stream($opsrc,$wfile);
14.在HTTP 1.0中,状态码401的含义是?;如果返回“找不到文件”的提示,则可用 header 函数,其语句为?
答:①HTTP/1.0 401 代表:未授权。 ②可用 header("HTTP/1.0 404 Not Found");
15.在PHP中,heredoc是一种特殊的字符串,它的结束标志必须?
答: ......
标识符;
结束标识符前不能有任何其它字符!
找工作中常见的PHP面试题及答案
http://www.js4j.com/tech/php/467.html

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
