[PHP newbie Interview Questions] Really, I hate someone else for modifying my resume. Sorry ('shanghai') sorry ~!

Source: Internet
Author: User
Tags php definition

My friend submitted my resume for me. By the way, I felt that my resume was not concise enough. I deleted several project experiences and simplified the introduction of all projects. What's worse, I changed my undergraduate school in a confused way, (-_-) B!

So I started a PHP job interview with a confidence value of 0. Really, PHP has never been learned, and I naturally won't, and he, this is phper, doesn't even, ('shanghai ('﹏′)

PS: all the answers to the following questions come from the Internet.

Question 1:Significance of Stored Procedures

Stored procedures consist of SQL statements and flow control statements.

Its functions include:

  • Accept parameters;
  • Call another process;
  • Return a status value to the call process or batch process, indicating that the call is successful or failed;
  • Return several parameter values to the call process or batch process to provide dynamic results for the caller;
  • Run in remote SQL Server.

Advantages:

  • Stored procedures are pre-compiled, so the execution speed of stored procedures is very fast.
  • Stored procedures and data to be processed are stored on the same computer running SQL Server. Using Stored Procedures to query local data is naturally very efficient.
  • Generally, a stored procedure is called by the client through the name of the stored procedure, reducing the amount of network transmission and adding the system speed.
  • Stored Procedures also have convenient features like C-language subfunctions that are called and return values.

Question 2:Common VI commands

Case Sensitive:

K, J, H, l -- move the cursor up or down

100g: Jump the cursor to 100 rows

CTRL + G/G: Click the cursor to report the number of rows and columns

W, B: The cursor skips a word forward or backward.

I, R: Insert before the cursor, replace at the cursor

CW, DW: Change (replace)/delete the word where the cursor is located (C = change, D = delete)

X, d $, DD -- delete a character, all characters from the cursor position to the end of the line, and the whole line command

/String: Search for the string, N for the next, and N for the previous

YY, p -- copy a row to the clipboard (which does not seem to be the system clipboard)/command to retrieve the content in the clipboard

: R/etc/passwd: Read/etc/passwd at the cursor position in the opened file

: 3R/etc/passwd indicates reading the file content in the next row of row 3rd: Row 4th

: W/tmp/1 temporarily saved to/tmp/1.

: 20, 59 w/tmp/1 only store contents between 20th and 59 rows into a file/tmp/1

Add more

Question 3:Can the "11" in PHP be compared with the integer 10?

Yes

If you compare an integer with a string, the string is converted to an integer.

Compare two numeric strings as integers.

When a string is evaluated as a number, the result type and value are determined according to the following rules:

If any one of the characters includes ".", "E", or "e", the string is treatedFloatOtherwise, it is treated as an integer.

This value is determined by the first part of the string. If the string starts with a valid number, this number is used as its value. Otherwise, the value is 0. valid numeric data starts with an optional plus or minus sign, followed by one or more numbers (including decimal scores), followed by an optional index. An index is an "E" or "E" followed by one or more numbers.

<? PHP
$ Foo = 1 + "10.5"; // $ foo is float (11.5)
$ Foo = 1 + "-1.3e3"; // $ foo is float (-1299)
$ Foo = 1 + "bob-1.3e3"; // $ foo is INTEGER (1)
$ Foo = 1 + "bob3"; // $ foo is INTEGER (1)
$ Foo = 1 + "10 small pigs"; // $ foo is INTEGER (11)
$ Foo = 4 + "10.2 little piggies"; // $ foo is float (14.2)
$ Foo = "10.0 pigs" + 1; // $ foo is float (11)
$ Foo = "10.0 pigs" + 1.0; // $ foo is float (11)
?>

<? PHP

If ("" = 0)
{
Echo "yes"; // output "yes"
}


Var_dump (0 = "A"); // 0 = 0-> true
Var_dump ("1" = "01"); // 1 = 1-> true
Switch (""){
Case 0:
Echo "0 ";
Break;
Case "A": // never reached because "A" is already matched with 0
Echo "";
Break;
}
?>

Question 4:Extract data from text to a table

<? PHP

$ Hostname = "localhost ";
$ Username = "root ";
$ Password = "root ";
$ Dbname = "testphp ";
$ Link = mysql_connect ($ hostname, $ username, $ password );
If (! $ Link ){
Die ('could not connect: '. mysql_error ());
}
Echo 'ccted successfully ';

Mysql_select_db ("$ dbname ");
$ Mydata = file ("data.txt ");
$ N = count ($ mydate );
Var_dump ($ N );
For ($ I = 0; $ I <$ N; $ I ++ ){
$ DATA = explode (",", $ mydata [$ I]);
$ STR = "insert into entity_user values ('$ data [0]', '$ data [1]')";
$ Result = mysql_query ($ Str );
If (! $ Result ){
Die ('invalid query: '. mysql_error ());
}

}
Mysql_close ();
Echo "OK ";
?>

Data.txt:

1, yangyh
2, abcdefg
3. gdfdsfs
5, fdsgafd
6. Yang

Question 5:Change a column name in MySQL

Alter table entity_user change name newnameVarchar (50); // type required

 

Question 6:PHP definition constant

 

Define ("constant", "Hello world .");

Question 7:Require require_once include include_once

 

1. Include ()
Include (/path/to/filename)
The include () Statement will contain a file at the location where it is called. A file contains the same content as the data copied to the file where the statement is located.
Parentheses can be ignored when include () is used.
You can execute the include () statement according to the conditions. The use of include () in conditional statements has a strange phenomenon. It must be enclosed in statement block braces or enclosed by other statements.

2. include_once ()
Include_once (filename)
The role of the include_once () function is the same as that of the include function, but it will first verify whether the file is included. If it already exists, revoke de_once is not executed. Otherwise, the file must be included. This is the same as include.
3. Require ()
Require (filename)
To a large extent, require () is the same as include. A template file is included in the location where the require call is located.
There are two important differences between require and include. First, regardless of the location of require, the file will be included in the script where require appears. For example,Even if require is placed in an if statement whose calculation result is false, it still contains the specified file.
The second important difference is:When a require error occurs, the script stops running. When the include clause is used, the script continues to run..
4. require_once ()
Require_once (filename)
As the website grows bigger, some files may be repeatedly contained. This may not be a problem,However, after modifying the variable of the contained file, it is overwritten because it contains the original file again., You may not want this to happen. Another problem may also occur, that is, the conflict of letters in the file. Use require_once to solve these problems.
The require_once function ensures that the file is only contained once. When you encounter require_once and try to include the same file later, it will be ignored

Http://dev.firnow.com/course/4_webprogram/php/phpjs/200824/98804.html

Question 8:Difference between $ A and $

$ N = 'a ';
$ A = 5;
Var_dump ($ n); // int (5)

PHP to this level... You can get all the variable values.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.