Windows OS:
Config php.ini (php-cli.ini)
;extension=php_openssl.dll
remove ; (comment char)
extension=php_openssl.dll
Linux OS:
If the php had not compile with the option –with-openssl, then add the option and recomplie it.
Build mấy cái đơn giản thì chả cần framework mà làm gì, cứ require với include mà giã! Nhớ lại ngày trước toàn include “openDB.php”, include “closeDB.php” ^^ thấy hay phết. Hôm nay thay đổi tí cho nó có không khí (cái gì mãi cũng nhàm :p), tạo hứng thú với cốt đinh
File: connect_db.php
$conn = mysql_connect('pvh', 'huypv', 'oHr61th3') or die("Connect failed to MySQL Server");
mysql_select_db('xxx', $conn) or die("Select db failed");
register_shutdown_function('closeDBConnection');
function closeDBConnection() {
global $conn;
if ($conn) mysql_close($conn);
}
File: index.php
require_once "connect_db.php";
function execSQL() {
global $conn;
//...
}
// execSQL();
# Không phải lo đóng connection
$.ajax({
url: “/xxx/search.php”,
type: “POST”,
contentType: “application/x-www-form-urlencoded; charset=UTF-8″,
data: “term=chống phá cách mạng, tuyên truyền phản động, xuyên tạc chủ nghĩa Mác – như thế là sai&_r=25251325″,
success: function(data) {
//console.log(data);
alert(data);
}
});
February 10th, 2010
admin
Function MoneyFromNote(ByVal note As String)
Dim RE As RegExp, REMatches As MatchCollection, REMatch As Match
Set RE = CreateObject("vbscript.regexp")
With RE
.MultiLine = False
.Global = True
.IgnoreCase = True
.Pattern = "([\+0-9\.,]+)([MK])"
End With
Set REMatches = RE.Execute(note)
r = 0
For i = 0 To REMatches.Count – 1
Set REMatch = REMatches.Item(i)
unit = REMatch.SubMatches(1)
num = REMatch.SubMatches(0)
num = Replace(num, ",", ".")
If unit = "M" Then
va = num * 1000000
ElseIf unit = "K" Then
va = num * 1000
End If
If Mid(num, 1, 1) = "+" Then va = 0 – va
'MsgBox num & " " & unit & " = " & va
r = r – va
Next
'MsgBox r
MoneyFromNote = Int(r)
End Function
‘Usage example
‘=MoneyFromNote(”Quần đùi: 30K; Áo ba lỗ: 25K; Thịt ba chỉ: 15K”)
‘Sẽ thu được: -70000
