Home Backend Development PHP Tutorial PHP programmer interview sharing_PHP tutorial

PHP programmer interview sharing_PHP tutorial

Jul 13, 2016 am 10:28 AM
programmer

Interview summary

Today I went to a famous IT company in Beijing for an interview as a PHP programmer. Is this the first time in your life? Why aren't you nervous? Am I sick? No, this is called confidence.

First, do some written test questions.
1.What data structure is used by mysql database index? What are the benefits of doing this?
You can refer to this blog post: http://blog.csdn.net/ant_ren/article/details/2932068


2. There are two strings a and b. Determine whether string b appears in a. Case is not considered. .

My answer is: use the stripos() function to solve it.

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

Expansion:
But if the order is not considered, ask whether all the characters in the string b appear in a. . .
Then we need to use loops to solve it. Solutions are provided below:
$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. What open source frameworks do you know?
I wrote some based on my own experience:
Laravel, PHP, jQuery. . .


4. Briefly explain session and cookie. If cookies are turned off, is the session available?
What I wrote is relatively simple:
The session is stored on the server side, and the cookie is stored on the client side. There is no direct connection between the two.
For accessing other pages. PHP_SESSIONID is placed on the browser side as a temporary cookie.
Every time the browser makes a request, it will bring the sessionid in the http header to identify itself.
If cookies are disabled, they will be automatically placed behind the URL for delivery.


5. Database optimization plan
Find this yourself on the Internet.


6. Design a Timer class to calculate the running time of the program and simply call it.
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

The following is a simple version.

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. Things you should pay attention to when building a composite index.
(1) For a table, if there is a composite index on (col1, col2), there is no need to create a single index on col1 at the same time.
(2) If the query conditions require it, you can add a composite index on (col1, col2) when there is already a single index on col1, which will improve the efficiency to a certain extent.
(3) There are not many benefits in establishing a composite index with multiple fields (including 5 or 6 fields) at the same time. Relatively speaking, establishing an index with multiple narrow fields (containing only one, or at most 2 fields) can achieve greater results. Great efficiency and flexibility.


8. Design a database table. This data table is used to store frequently inserted and queried URL data.
And explain why it is designed this way.
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


That's how I set it up.
For frequent insertions and deletions, I think the database storage engine should use MyISAM.
It would be better if we create an index on the url and name fields.

It’s not that I want to write simply. There are so many questions on just one A4 paper.

Doesn’t this force me to write simpler? But I still made some stupid mistakes. I'm trying to correct it.

A little benefit to share with everyone.

Best Wishes.



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/802113.htmlTechArticleInterview Summary Today I went to a famous IT company in Beijing for an interview with a PHP programmer. Is this the first time in your life? Why aren't you nervous? Am I sick? No, this is called self-confidence. First, do something...
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

Revealing the appeal of C language: Uncovering the potential of programmers Revealing the appeal of C language: Uncovering the potential of programmers Feb 24, 2024 pm 11:21 PM

The Charm of Learning C Language: Unlocking the Potential of Programmers With the continuous development of technology, computer programming has become a field that has attracted much attention. Among many programming languages, C language has always been loved by programmers. Its simplicity, efficiency and wide application make learning C language the first step for many people to enter the field of programming. This article will discuss the charm of learning C language and how to unlock the potential of programmers by learning C language. First of all, the charm of learning C language lies in its simplicity. Compared with other programming languages, C language

Make money by taking on private jobs! A complete list of order-taking platforms for programmers in 2023! Make money by taking on private jobs! A complete list of order-taking platforms for programmers in 2023! Jan 09, 2023 am 09:50 AM

Last week we did a public welfare live broadcast about "2023PHP Entrepreneurship". Many students asked about specific order-taking platforms. Below, php Chinese website has compiled 22 relatively reliable platforms for reference!

what do programmers do what do programmers do Aug 03, 2019 pm 01:40 PM

Programmer's job responsibilities: 1. Responsible for the detailed design, coding and organization and implementation of internal testing of software projects; 2. Assist project managers and related personnel to communicate with customers and maintain good customer relationships; 3. Participate in demand research and project feasibility performance analysis, technical feasibility analysis and demand analysis; 4. Familiar with and proficient in the relevant software technologies for delivering software projects developed by the software department; 5. Responsible for timely feedback on software development situations to the project manager; 6. Participate in software development and maintenance Solve major technical problems during the process; 7. Responsible for the formulation of relevant technical documents, etc.

2023过年,又限制放烟花?程序猿有办法! 2023过年,又限制放烟花?程序猿有办法! Jan 20, 2023 pm 02:57 PM

本篇文章给大家介绍如何用前端代码实现一个烟花绽放的绚烂效果,其实主要就是用前端三剑客来实现,也就是HTML+CSS+JS,下面一起来看一下,作者会解说相应的代码,希望对需要的朋友有所帮助。

520 programmers' exclusive way to express romantic feelings! Can't refuse! 520 programmers' exclusive way to express romantic feelings! Can't refuse! May 19, 2022 pm 03:07 PM

520 is approaching, and he is here again for the annual show of tormenting dogs! Want to see how the most rational code and the most romantic confession can collide? Let’s take you through the most complete and complete advertising code one by one to see if the romance of programmers can capture the hearts of your goddesses?

A brief analysis of how to download and install historical versions of VSCode A brief analysis of how to download and install historical versions of VSCode Apr 17, 2023 pm 07:18 PM

Download and install historical versions of VSCode VSCode installation download installation reference VSCode installation Windows version: Windows10 VSCode version: VScode1.65.0 (64-bit User version) This article

List of the best Windows 11 terminal emulators in 2022: Top 15 recommendations List of the best Windows 11 terminal emulators in 2022: Top 15 recommendations Apr 24, 2023 pm 04:31 PM

Terminal emulators allow you to emulate the functionality of a standard computer terminal. With it, you can perform data transfers and access another computer remotely. When combined with advanced operating systems like Windows 11, the creative possibilities of these tools are endless. However, there are many third-party terminal emulators available. Therefore, it is difficult to choose the right one. But, just as we do with the must-have Windows 11 apps, we've selected the best Terminals you can use and increase your productivity. How do we choose the best Windows 11 terminal emulator? Before selecting the tools on this list, our team of experts first tested them for compatibility with Windows 11. We also checked them

See all articles