Home php教程 php手册 php程序员面试分享

php程序员面试分享

Jun 21, 2016 am 08:47 AM
gt quot this timer

面试总结

今天去了北京著名IT公司进行PHP程序员的面试。这是人生第一次么,怎么不紧张?我是不是有病。不是,这叫自信呵.

首先是做一些笔试题。
1.mysql数据库索引使用的数据结构?这样做的好处是?
可以参考这篇博文:http://blog.csdn.net/ant_ren/article/details/2932068


2.有两个字符串a和b,判断b字符串是否出现在a中。不考虑大小写。。

我的答案是:使用stripos()这个函数来解决的。

if(stripos($a,$b)>-1)
	echo "b in a";
else
	echo "b not in a";
Copy after login

拓展:
但是如果是不考虑顺序的话,问b字符串中的字符是否全部出现在a中。。。
那我们就需要用循环来解决的。下面提供解决方案:
$b_arr = str_split($b);
for(var $i=0,$len = count($b_arr); $i < $len ;  ++$i){
	if(stripos($a,$b_arr[$i])==-1)
		return false;
	return true;
}
Copy after login

3.你知道的开源框架?
我按照自己的经验写了一些:
Laravel,PHP,jQuery。。。


4.简单解释session 和cookie。关闭cookie,session是否可用?
我写的比较简单:
session存储在服务器端,cookie存储在客户端。两者没有直接的联系。
对于访问其他的页面。PHP_SESSIONID是作为一个临时cookie放在浏览器端的。
每次浏览器发出的请求,都会在http header里 带上 sessionid来标识自己。
如果禁用cookie,那么会自动放在url后面进行传递。


5.数据库优化方案
这个自己在网络上找一下。


6.设计一个Timer类,用来计算程序运行的时间,并且简单的调用它。
class Timer { 
	private $StartTime = 0;//程序运行开始时间 
	private $StopTime = 0;//程序运行结束时间 
	private $TimeSpent = 0;//程序运行花费时间 


	function start(){//程序运行开始 
		$this->StartTime = microtime(); 
	} 
	function stop(){//程序运行结束 
		$this->StopTime = microtime(); 
	} 
	function spent(){//程序运行花费的时间 
		if ($this->TimeSpent) { 
			return $this->TimeSpent; 
		} else { 
			list($StartMicro, $StartSecond) = explode(" ", $this->StartTime); 
			list($StopMicro, $StopSecond) = explode(" ", $this->StopTime); 
			$start = doubleval($StartMicro) + $StartSecond; 
			$stop = doubleval($StopMicro) + $StopSecond; 
			$this->TimeSpent = $stop - $start; 
			return substr($this->TimeSpent,0,8)."秒";//返回获取到的程序运行时间差 
		} 
	} 
} 
$timer = new Timer(); 
$timer->start(); 
//...程序运行的代码 
$timer->stop(); 
echo "程序运行时间为:".$timer->spent(); 
Copy after login

下面是简单版的。

class Timer{
	private $t = 0;


	public function start(){
		$this->t = microtime(true);
	}


	public function stop(){
		return microtime(true)- $this->t;
	}
}


$time = new Timer();
$time->start();
//do somethings...
$t = $time->stop();
Copy after login


7.建立复合索引应该注意的事项。
(1)对一张表来说,如果有一个复合索引 on (col1,col2)就没有必要同时建立一个单索引 on col1。
(2)如果查询条件需要,可以在已有单索引 on col1的情况下,添加复合索引on (col1,col2),对于效率有一定的提高。
(3)同时建立多字段(包含5、6个字段)的复合索引没有特别多的好处,相对而言,建立多个窄字段(仅包含一个,或顶多2个字段)的索引可以达到更好的效率和灵活性。


8.设计一张数据库表。该数据表用来存储经常插入和查询的url数据。
并解释为什么这么设计的原因。
create table url(
	`id` int(11) not null primary key auto_increment comment "主键",
	`url` varchar(255) not null comment "url 内容",
	`name` varchar(50) comment "url对应的名称"
)ENGINE=MyISAM
Copy after login


我是这么建立的。
经常插入和删除,我觉的数据库存储引擎应该使用MyISAM。
如果再在url,name字段上建立一个索引就更好了。

不是我想简单写啊。这么多题目就一张A4纸啊。

这不是逼着我写简单点吗?不过我还是犯了一些低级的错误。我正在努力改正。

一点福利,分享给大家。

Best Wishes.





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)

What are the differences between Huawei GT3 Pro and GT4? What are the differences between Huawei GT3 Pro and GT4? Dec 29, 2023 pm 02:27 PM

Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Fix: Snipping tool not working in Windows 11 Fix: Snipping tool not working in Windows 11 Aug 24, 2023 am 09:48 AM

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

How to Fix Can't Connect to App Store Error on iPhone How to Fix Can't Connect to App Store Error on iPhone Jul 29, 2023 am 08:22 AM

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Let's talk about why Vue2 can access properties in various options through this Let's talk about why Vue2 can access properties in various options through this Dec 08, 2022 pm 08:22 PM

This article will help you interpret the vue source code and introduce why you can use this to access properties in various options in Vue2. I hope it will be helpful to everyone!

An article that understands this point and catches up with 70% of front-end people An article that understands this point and catches up with 70% of front-end people Sep 06, 2022 pm 05:03 PM

A colleague got stuck due to a bug pointed by this. Vue2’s this pointing problem caused an arrow function to be used, resulting in the inability to get the corresponding props. He didn't know it when I introduced it to him, and then I deliberately looked at the front-end communication group. So far, at least 70% of front-end programmers still don't understand it. Today I will share with you this link. If everything is wrong If you haven’t learned it yet, please give me a big mouth.

Is watch4pro better or gt? Is watch4pro better or gt? Sep 26, 2023 pm 02:45 PM

Watch4pro and gt each have different features and applicable scenarios. If you focus on comprehensive functions, high performance and stylish appearance, and are willing to bear a higher price, then Watch 4 Pro may be more suitable. If you don’t have high functional requirements and pay more attention to battery life and reasonable price, then the GT series may be more suitable. The final choice should be decided based on personal needs, budget and preferences. It is recommended to carefully consider your own needs before purchasing and refer to the reviews and comparisons of various products to make a more informed choice.

请教怎么修改url某一参数的参数值呢?是要拆开了再拼回去吗 请教怎么修改url某一参数的参数值呢?是要拆开了再拼回去吗 Jun 13, 2016 am 10:24 AM

请问如何修改url某一参数的参数值呢?是要拆开了再拼回去吗?那么请问如何修改url某一参数的参数值呢?是要拆开了再拼回去吗?http://127.0.0.1/myo/newuser.php?mod=search&type=fastone比如现在我要修改mod=new要怎么做呢?------解决方案--------------------发送了请求

See all articles