1. Use PHP to print the time of the previous day in the format of 2012-4-12 10:11:22
echo date("<span Y-n-d H:i:s</span>",strtotime("<span -1 day</span>"));
format character [a: am, pm lowercase, A:AM, PM uppercase g hour, 12-hour clock n month no preceding 0]
strtotime() is used as follows
<span <?</span>php echo strtotime ("<span now</span>"), "<span \n</span>"; echo strtotime ("<span 10 September 2000</span>"), "<span \n</span>"; echo strtotime ("<span +1 day</span>"), "<span \n</span>"; echo strtotime ("<span +1 week</span>"), "<span \n</span>"; echo strtotime ("<span +1 week 2 days 4 hours 2 seconds</span>"), "<span \n</span>"; echo strtotime ("<span next Thursday</span>"), "<span \n</span>"; echo strtotime ("<span last Monday</span>"), "<span \n</span>"; <span ?></span>
2.echo() print() print_f() difference
echo() is a php statement, so it has no return value and can print simple data.
print() is a function with a return value and can print simple data.
print_r() is a function that can print complex (mix) data.
3. Common PHP template engines
Smarty EasyTemplatePHP
4. Which tools can be used for version control
SVN CVS
5. Function to implement character flipping
strrev($str);
6. Common methods to optimize Mysql database
(1). In terms of database design, this is the responsibility of the DBA and Architect. Design a well-structured database. When necessary, denormalize it (English is this: denormalize, I don’t know the Chinese translation), allowing some Data redundancy avoids JOIN operations to improve query efficiency
(2). In terms of system architecture design, table hashing is used to hash massive data into several different tables. Fast and slow tables only retain the latest data. , the slow table is a historical archive. Cluster, master server Read & write, slave server read only, or N servers, each machine is Master for each other
(3). (1) and (2) exceed the requirements of PHP Programmer , would be better, it doesn’t matter. Check whether there are fewer indexes
(4). Write efficient SQL statements and see if there are any inefficient SQL statements, such as full joins that generate Cartesian products, a lot Group By and order by, no limit, etc. When necessary, encapsulate the database logic into the stored procedure on the DBMS side. Cache the query results and explain each SQL statement
(5). All the results are required, only from the database Get the necessary data, such as querying the number of comments on an article, select count(*) ... where article_id = ? That's it. Don't select * first ... where article_id = ? Then msql_num_rows.
Transmit only the necessary SQL statement, for example, when modifying an article, if the user only modified the title, then update... set title = ? where article_id = ? Do not set content = ? (large text)
(6). When necessary Use different storage engines. For example, InnoDB can reduce deadlocks. HEAP can increase query speed by an order of magnitude.
7. Use PHP to obtain client IP and server IP
Client: $_SERVER[‘REMOTE_ADDR’] or getenv(‘REMOTE_ADDR’);
Server: gethostbyname(“baidu.com”);
8. Modify the session survival time
<?php session_start(); // 保存一天 $lifeTime = 24 * 3600; setcookie(session_name(), session_id(), time() + $lifeTime, "/"); ?>
SELECT username FROM members GROUP BY id ORDER BY count(posts) DESC LIMIT 0 , 10
10.简述如何得到当前执行脚本路径,包括所得到参数。
echo $_SERVER['SCRIPT_FILENAME']."?".$_SERVER['QUERY_STRING'];
11.mysql_fetch_row() 和mysql_fetch_array之间有什么区别?<br>mysql_fetch_row() 从和指定的结果标识关联的结果集中取得一行数据并作为数组返回。每个结果的列储存在一个数组的单元中,偏移量从 0 开始。mysql_fetch_array() 是 mysql_fetch_row() 的扩展版本。除了将数据以数字索引方式储存在数组中之外,还可以将数据作为关联索引储存,用字段名作为键名。
12.判断以下输出
$str1 = null; $str2 = false; echo $str1==$str2 ? '<span 相等</span>' : '<span 不相等</span>'; //相等 $str3 = '<span </span>'; $str4 = 0; echo $str3==$str4 ? '<span 相等</span>' : '<span 不相等</span>'; //相等 $str5 = 0; $str6 = '<span 0</span>'; echo $str5===$str6 ? '<span 相等</span>' : '<span 不相等</span>'; //不相等
13.写出以下结果
<span <?</span>php $test = '<span aaaaaa</span>'; $abc = & $test; unset($test); echo $abc; <span //aaaaaa</span> <span ?></span>
-----------未完待续-------------<br><br>