PHP face question Set and answer

Source: Internet
Author: User
Tags image processing library sprintf
    1. $a = Date ("y-m-d h:i:s", Strtotime ("1 day"));
    2. Print_r ($a);
Copy Code

2, Echo (), print (), Print_r () difference (3 points)

    1. Echo and print are not a function, it is a language structure
    2. int print (string $arg) with only one parameter
    3. Echo arg1,arg2; Multiple parameters can be output, return void
    4. Echo and print can only print out a string and cannot print out the structure
    5. Print_r can print out the structure
    6. Like what
    7. $arr = Array ("Key" = "value");
    8. Print_r ($arr);
Copy Code

3, the ability to make HTML and PHP separated from the use of the template (1 points) Smarty,phplib 4, which tools to use for version control? (1 points) Svn,git,cvs 5, how to implement string flipping? (3 points) English: Strrev ($a) Chinese or other text: Chinese: gb2312, code is encoded using GB2312

    1. function reverse ($STR)
    2. {
    3. $ret = "";
    4. Len=mbstrwidth (str, "gb2312");
    5. for (i=0;i< len;i++)
    6. {
    7. Arr[]=mbsubstr (str, $i, 1, "gb2312");
    8. }
    9. Return implode ("", Array_reverse ($arr));
    10. }
    11. Print_r (Reverse ("Hello"));
Copy Code

6, optimize the MySQL database method. (4 points, more than a lot) statement aspect: 1 use index, increase query Efficiency 2 query statement, improve index hit ratio database involves aspects: 1 construct sub-database table, improve the storage and expansion capacity of databases 2 use different storage engines as needed 7, PHP meaning (1 points) Super text preprocessing language hypertext preprocessor 8, MySQL gets the current time function is?, formatted Date function is (2 points)

    1. Current_timestamp ()
    2. Date_format ()
    3. Select Date_format ("2011-11-21 10:10:10", "%y-%m-%d");
Copy Code

9, the implementation of the text string interception without garbled method. (3 points) Mb_substr ($STR, 1, 1, "gb2312"); 10. Have you ever used version control software? If you have the name of the version control software you are using? (1 points) Svngit 11, have you ever used a template engine? If you have the name of the template engine you are using? (1 points) Smarty 12, please briefly describe your most proud of the development (4 points) xxx 13, for the large-volume website, what method do you use to solve the traffic problem? (4 points) 1 Efficient use of cache, increase cache hit ratio 2 use CDN for static files to store and accelerate 4 ideas to reduce the use of the database 5 see where the bottleneck of the statistics is 14, write out the code that shows the client IP and server IP in PHP 1) $_server[" REMOTE_ADDR "]$_server[" server_addr "] 15, what is the difference between the statement include and require? To avoid including the same file multiple times, you can use (?) Statements instead of them? (2 points) in the case of failure: include produces a warning, and require produces a direct error interrupt require loading the include at run time to load Require_onceinclude_once 16, How to modify the duration of the session (1 points). Session_set_cookie_params 17, there is a web address, such as the Script Academy home page: http://bbs.it-home.org/index.html, how to get its content? ($) File_get_contentscurl 18, in HTTP 1.0, the meaning of status code 401 is (?); If you get a hint that "file not found" is returned, the header function is available and the statement is (?);( 2 min) Unauthorized header ("http/1.0 404 Not Found"); in fast CGI: header ("status:404 not Found"); 19, in PHP, Heredoc is a special string, its end flag must? (1 points) in pairs appears $ A = < < p="">

    1. $str = "jianfeng@126.com";
    2. Regex= "([A?z0?9\.?] +) @ ([\da?z\.?] +)\. ([A?z\.] 2,6) "; Regular
    3. Return Preg_match (REGEX,STR)
Copy Code

26. Describe how to get the current execution script path, including the obtained parameters. (2 points) $ARGC--Get the number of parameters $argv--Get the parameter list 27. How to modify the lifetime of the session. (1 points) Session_set_cookie_params 28, JS Form popup dialog function is? Get the input focus function? (2 points) alert () Confirm () promopt () focus () 29, JS's steering function is? How to introduce an external JS file? (2 points) What is the difference between window.location.href= "#" 30, Foo () and @foo ()? (1 points) @ for all warning Ignore 31, how to declare a class with no methods and properties named "MyClass"? (1 points) class myclass{} 32, how do I instantiate an object named "MyClass"? (1 points) $myclass = new MyClass (); 33. How do you access and set the properties of a class? (2 points)

    1. Class A
    2. {
    3. Public $name = "a";
    4. }
    5. $a = new A ();
    6. n=a->name;
    7. Print_r ($n);
Copy Code

34. What is the difference between mysql_fetch_row () and mysql_fetch_array? (1 points) mysql_fetch_array () is an extended version of Mysql_fetch_row (). In addition to storing data as a numeric index in an array, you can store the data as an associated index, using the field name as the key name.

    1. mysql_connect ("localhost", "Mysql_user", "Mysql_password") or
    2. Die ("Could not connect:". Mysql_error ());
    3. mysql_select_db ("MyDB");
    4. $result = mysql_query ("Select ID, name from mytable");
    5. while (Row=mysqlfetcharray (result, Mysql_assoc)) {
    6. printf ("ID:%s Name:%s", row["id"],row["name"]);
    7. }
    8. Mysql_free_result ($result);
Copy Code

35, what is the GD library for? (1 points) dynamic open image processing Library 36, pointing out some ways to enter HTML code in PHP. (1 points)

    1. echo "{html}"
    2. Echo <<>
    3. {html}
    4. Eod
Copy Code

37. Which of the following functions can open a file to read and write to a file? (1 points) C (a) Fget () (b) File_open () (c) fopen () (d) Open_file () 38, which of the following option does not add John to the users array? (1 points) b

    1. (a) $users [] = ' John ';
    2. (b) Array_add ($users, ' John ');
    3. (c) Array_push ($users, ' John ');
    4. (d) $users | | = ' John ';
Copy Code

39, the following program will enter whether or not? (1 points) 10

    1. $num = 10;
    2. function Multiply () {
    3. Num=num * 10;
    4. }
    5. Multiply ();
    6. Echo $num;
Copy Code

40, use PHP to write a simple query, find out all the name "Zhang San" content and print out (2) Table name username Tel Content Date 313,333,663,366 College graduation 2006-10-11 313,612,312,331 bachelor degree 20 06-10-15 Zhang 021-55665566 Secondary school 2006-10-15 please complete the code according to the above topic:

    1. $mysql _db=mysql_connect ("local", "Root", "pass");
    2. @mysql_select_db ("db", $mysql _db);
    3. $sql = sprintf ("Select * from%s where username = '%s '",
    4. "Table name",
    5. "Zhang San");
    6. Values=mysqlquery (SQL);
    7. while (Item=mysqlfetchqueryarray (values))
    8. {
    9. echo sprintf ("Username:%s, phone%s, education:%s, Graduation Date:%s",
    10. item[′username′],item[' Tel '], item[′content′],item[' Date '
    11. );
    12. }
Copy Code

41, how to use the following class, and explain what the following mean? (3)

    1. Class test{
    2. function Get_test ($num) {
    3. NUM=MD5 (MD5 (num). " En ");
    4. return $num;
    5. }
    6. }
    7. $test = new test ();
    8. Ret=test->get_test (11);
    9. Print_r ($ret); exit;
Copy Code

The 32-bit string that is generated after NUM is MD5 encoded A1 and "en" are associated with MD5 encoding 42, writing out the format of the SQL statement: INSERT, UPDATE, DELETE (4) Table name username Tel Content date 313,333,663,366 College graduation 2006-10-11 Zhang 313,612,312,331 Bachelor's degree 2006-10-15 021-55665566 Secondary School graduation 2006-10-15 (a) A new record (Xiao Wang 13254748547 High school graduation 2007-05-06) please Add a SQL statement to the table insert into table name values (' Xiao Wang ', ' 13254748547 ', ' High School graduate ', ' 2007-05-06 ') (b) Please update the Zhang San time with the SQL statement to the current system time, the Update table name set Date = GETDATE () where username = "Zhang San" (c) write out delete all records named Zhang Xi Delete from indicates where username = "Four" 43, please write out the data type (int char varchar date The meaning of time text); What is the difference between varchar and char (2 points) int integer char store fixed length varchar store variable long datetime time text store variable length varchar is variable length char (20) fixed length 44, mysq self-increment type (usually table ID field) It must be set to (?)  Field (1 points) Auto_increment 45, write out the following program output results (1 points) $b = 201;  $c = 40;  A=b> $c? 4:5; echo $a;? >4

46. Is there a function to detect whether a variable is set or not? is the function empty? (2 points) isset () empty () 47, the function that gets the total number of query result sets? (1 points) mysql_num_rows () 48,

    1. $arr = Array (' James ', ' Tom ', ' Symfony '); Please print out the value of the first element (1 points)
    2. Print_r ($arr [0]);
    3. Reset ($arr);
    4. Print_r (current ($arr));
    5. Print_r (Array_shift ($arr)); (Programmer's Home bbs.it-home.org editing)
Copy Code

49, the value of the array of 41 is separated and combined into a string output (1 points) implode 50, a=′abcdef′; Please remove the value of a and print out the first letter (1 points) $a [0];substr ($a, 0, 1); 51. Can PHP connect to a database such as SQL Server/oracle? (1 points) can have ready-made library 52, please write out the PHP5 permission control modifier (3 points) Publicprivate protected 53, write PhP5 constructor and destructor (2 min) public Function __construct () {} Public Function __destruct () {} programming question 1. Write a function that, as efficiently as possible, extracts the file's extension from a standard URL such as: http://www.sina.com.cn/abc/de/fg.php?id=1 needs to remove PHP or. php

    1. $url = "Http://www.sina.com.cn/abc/de/fg.php?id=1";
    2. Arr=parseurl (URL);
    3. Patharr=pathinfo (arr[' path ');
    4. Print_r ($patharr [' extension ']);
Copy Code

3. Write a function that calculates the relative path of two files, such as $a = '/a/b/c/d/e.php '; $b = '/a/b/12/34/c.php '; computes the relative path of B relative to a should be http://www.cnblogs.com/12/34/ C.php will be added.

    1. $a = '/a/b/c/d/e.php ';
    2. $b = '/a/b/12/34/c.php ';
    3. Gets the relative path of path relative to Conpath
    4. function Sgetrelativepath (Path,conpath)
    5. {
    6. Patharr=explode ("/", path);
    7. Conpatharr=explode ("/", Conpath);
    8. $dismatchlen = 0;
    9. For (I=0;i < count (Patharr); i++)
    10. {
    11. if (conpatharr[i]! = Patharr[i])
    12. {
    13. Dismatchlen=count (Patharr)-$i;
    14. Arrleft=arrayslice (Patharr, $i);
    15. Break
    16. }
    17. }
    18. Ret=strrepeat (".. /", Dismatchlen). Implode ("/", $arrleft);
    19. return $ret;
    20. }
    21. Print_r (Sgetrelativepath (b,a));
Copy Code

3. Write a function that can traverse all the files and subfolders under a folder.

    1. function Agetallfile ($folder)
    2. {
    3. $afilearr = Array ();
    4. if (Is_dir ($folder))
    5. {
    6. Handle=opendir (folder);
    7. while ((File=readdir (handle))!== false)
    8. {
    9. If it is. Or. Then skip
    10. if (file== "." | | File = = "..")
    11. {
    12. Continue
    13. }
    14. if (Is_file (folder. " /". File))
    15. {
    16. Afilearr[]=file;
    17. }
    18. else if (Is_dir (folder. /". File))
    19. {
    20. Afilearr[file] = agetallfile (folder. " /". file);
    21. }
    22. }
    23. Closedir ($handle);
    24. }
    25. return $afilearr;
    26. }
    27. $path = "/home/test/sql";
    28. Print_r (Agetallfile ($path));
Copy Code
  • 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.