PHP LAMP Engineer Test Paper Question 1
What does <? echo count ("123") ?> print out?
A) 3
B) False
C) Null
D) 1
E) 0
Question 2
Which of the following snippets prints a representation of 42 with two decimal places?
A) printf("%.2d/n", 42);
B) printf("%1.2f/n", 42);
C) printf("%1.2u/n", 42);
Question 3
Given
$text = 'Content- Type: text/xml';
Which of the following prints 'text/xml'?
A) print substr($text, strchr($text, ':'));
B) print substr($text, strchr($text, ':') + 1);
C) print substr($text, strpos($text, ':') + 1);
D) print substr($text, strpos($text, ':') + 2);
E) print substr($text, 0, strchr($text, ':')
Question 4
What is the value of $a?
<?php
$a = in_array('01', array('1')) == var_dump('01' == 1);
?>
A) True
B) False
Question 5
What is the value of $result in the following PHP code?
<?php
function timesTwo($int) {
$int = $int * 2;
}
$int = 2;
$result = timesTwo($int);
?>;
Answer: NULL
Question 6
The code below ___________ because ____________.
<?php
class Foo {
?>
<?php
function bar() {
print "bar";
}
}
?>
A) will work, class definitions can be split up into multiple PHP blocks.
B) will not work, class definitions must be in a single PHP block.
C) will not work, class definitions must be in a single file but can be in multiple PHP blocks.
D) will work, class definitions can be split up into multiple files and multiple PHP blocks.
Question 7
When turned on, ____________ will _________ your script with different variables from HTML forms and cookies.
A) show_errors, enable
B) show_errors, show
C) register_globals, enhance
D) register_globals, inject
Question 8
What will be the output of the following PHP code:
<?php
echo count(strlen("http://php.net"));
?>
Answer: 1
Question 9
What is the best all-purpose way of comparing two strings?
A) Using the strpos function
B) Using the == operator
C) Using strcasecmp()
D) Using strcmp()
Question 10
What is the difference between "print()" and "echo()"?
Answer: print is a function,echo is a language construct
Sina: 1. 寫一個函數,儘可能高效的,從一個標準 url 裡取出檔案的副檔名
例如: http://www.sina.com.cn/abc/de/fg.php?id=1 需要取出 php 或 .php
2. 在 HTML 語言中,頁面頭部的 meta 標記可以用來輸出檔案的 編碼格式,以下是一個標準的 meta 語句
<META http-equiv='Content- Type' content='text/html; charset=gbk'>
請使用 PHP 語言寫一個函數,把一個標準 HTML 頁面中的類似 meta 標記中的 charset 部分值改為 big5
請注意:
(1) 需要處理完整的 html 頁面,即不光此 meta 語句
(2) 忽略大小寫
(3) ' 和 " 在此處是可以互換的
(4) 'Content-Type' 兩側的引號是可以忽略的,但 'text/html; charset=gbk' 兩側的不行
(5) 注意處理多餘空格
6.設計一個網頁,使得開啟它時彈出一個全屏的視窗,該視窗中有一個文字框和一個按鈕。使用者在文字框中輸入資訊後點擊按鈕就可以把視窗關閉,而輸入的資訊卻在主網頁中顯示。
Yahoo: 1. Which of the following will not add john to the users array? 複製內容到剪貼簿
代碼: 1. $users[] = 'john';
2. array_add($users,'john');
3. array_push($users,'john');
4. $users ||= 'john'; 2. What's the difference between sort(), asort() and ksort? Under what circumstances would you use each of these?
3. What would the following code print to the browser? Why? 複製內容到剪貼簿
代碼: $num = 10;
function multiply(){
$num = $num * 10;
}
multiply();
echo $num; 4. What is the difference between a reference and a regular variable? How do you pass by reference & why would you want to?
5. What functions can you use to add library code to the currently running script?
6. What is the difference between foo() & @foo()?
7. How do you debug a PHP application?
8. What does === do? What's an example of something that will give true for '==', but not '==='?
9. How would you declare a class named “my class” with no methods or properties?
10. How would you create an object, which is an instance of “myclass”?
11. How do you access and set properties of a class from within the class?
12. What is the difference between include & include_once? include & require?
13. What function would you use to redirect the browser to a new page? 複製內容到剪貼簿
代碼: 1. redir()
2. header()
3. location()
4. redirect() 14. What function can you use to open a file for reading and writing? 複製內容到剪貼簿
代碼: 1. fget();
2. file_open();
3. fopen();
4. open_file(); 15. What's the difference between mysql_fetch_row() and mysql_fetch_array()?
16. What does the following code do? Explain what's going on there. 複製內容到剪貼簿
代碼: $date='08/26/2003';
print ereg_replace(“([0-9]+)/([0-9]+)/([0-9]+)”,2/1/3,$date); 17. Given a line of text $string, how would you write a regular expression to strip all the HTML tags from it?
18. What's the difference between the way PHP and Perl distinguish between arrays and hashes?
19. How can you get round the stateless nature of HTTP using PHP?
20. What does the GD library do?
21. Name a few ways to output (print) a block of HTML code in PHP?
22. Is PHP better than Perl? – Discuss.
Baidu:第一部分:
4.資料庫最佳化:
有一個表 PRODUCT(ID,NAME,PRICE,COUNT);
在執行一下查詢的時候速度總是很慢:
SELECT * FROM PRODUCT WHERE PRICE=100;
在price欄位上加上一個非聚簇索引,查詢速度還是很慢。
(1)分析查詢慢的原因。
(2)如何進行最佳化。
5.CREATE TABLE topid{
topicId int not null primary key auto_increment,
title text,
author varchar(30),
content blob,
isDeleted int
...... //好像在author上定義了一個索引
}
CREATE TABLE reply{
topicId int foreign key,
replyId int primary key auto_increment,
replyAuthor varchar(30),
replyTime datetime,
context blob
....... //定義了一個索引和key
}
一個為主題表,一個為回複表。
1.問從效能上考慮,這樣做有什麼不足。
2.查詢回複時間不超過一個特定的時間段,回複的作者名字以MIKE開頭的主題
的title,以如下的查詢:
select * from topic where replyid in (select replyid from reply where
replyAuthor like 'mike%' and (currentTime()-replyTime<specialTime))
從效能上考慮上述的查詢語句有什麼不足。
如何進行最佳化。
酷訊:PHP&HTML 基礎操作題
● 有三個 php檔案位於同一目錄下,內容為
a.php:-------
<?php function fa() { echo "in Function A/n"; }?>
b.php:-------
<?php include 'a.php'; ?>
<?php function fb() { fa(); echo "in Function B/n"; } ?>
c.php:-------
<?php include 'a.php'; ?>
<?php include 'b.php'; ?>
<?php fa(); fb(); ?>