PHP interview part 2

WBOY
Release: 2016-07-29 08:56:50
Original
663 people have browsed it

I went to see a doctor again in the past two days. After the interview, I felt hopeless, haha. Okay, without further ado, let’s get straight to the topic.

1. Let’s talk about the difference between session and cookies.
If you don’t want to talk anymore, just go to Baidu on your own.
But let’s just say that session_id is generally stored in cookies and passed to the server through the header. If cookies are disabled, it can only be passed through the URL.

2. Write the results of the following program.

<code><span><span><?php</span><span><span>function</span><span>changeNum</span><span>(<span>$input</span>)</span>{</span><span>$input</span> = <span>100</span>;
 }
  <span><span>function</span><span>changeArray</span><span>(<span>$input</span>)</span>{</span><span>$input</span>[<span>'key'</span>] = <span>100</span>;
 }
  <span><span>function</span><span>changeObj</span><span>(<span>$input</span>)</span>{</span><span>$input</span>->key = <span>100</span>;
 }
  <span><span>function</span><span>changeStr</span><span>(<span>$input</span>)</span>{</span><span>$input</span> = <span>'100'</span>;
 }
 <span>$input</span> = <span>0</span>;
 changeNum(<span>$input</span>);
 <span>echo</span><span>$input</span>.<span>'</br>'</span>;

 <span>$input2</span>[<span>'key'</span>] = <span>0</span>;
 changeArray(<span>$input2</span>);
 <span>echo</span><span>$input2</span>[<span>'key'</span>].<span>'</br>'</span>;
<span>$input3</span> = <span>new</span> class1();
<span>$input3</span>->key = <span>0</span>;
 changeObj(<span>$input3</span>);
 <span>echo</span><span>$input3</span>->key.<span>'</br>'</span>;

<span>$input4</span> = <span>'123'</span>;
 changeStr(<span>$input4</span>);
 <span>echo</span><span>$input4</span>;
<span><span>class</span><span>class1</span>{</span>}
<span>?></span></span></span></code>
Copy after login

The main issues examined here are the storage and reference methods of data types.

3. How to exchange the values ​​of a and b without using the third variable.

<code><span>$a</span> = <span>1</span>;<span>$b</span> = <span>2</span>;
<span>list</span>(<span>$a</span>,<span>$b</span>)=<span>array</span>(<span>$b</span>,<span>$a</span>);
<span>echo</span><span>$a</span>.<span>$b</span>;</code>
Copy after login

There is another way to achieve this by intercepting strings, which will not be introduced here.

4. The difference between PDO and mysql.

Well, pdo is more powerful than php-mysql. Don't ask me where my awesomeness lies, I don't know.

5. Use at least two methods to implement the display encoding of the specified page

<code>header('content-<span><span>type</span>:<span>text</span>/<span>html</span>;<span>charset</span>=</span>utf-<span>8</span>');
<meta charset=<span>"utf-8"</span> /></code>
Copy after login

6. What does the return of 200 and 404 in the http request header mean?

200, indicating that the request was successful.
404, indicating that the requested resource does not exist.

I can only think of these few for now, I will add more when I think of them later.

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced the second part of the PHP interview, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!