Category Archives: Chỉ dẫn lập trình

xdebug not loaded as zend extension

I hate error, of course.
And I hate warning too.
How to fix this warning ^^ when using xdebug
Windows: Edit file php.ini (xác định đường dẫn file php.ini đã load = cách: gõ php –ini với php-cli, và tạo file phpinfo() với php-cgi)
[Xdebug]
zend_extension_ts=”C:/php/ext/php_xdebug.dll”

Còn cứ để comment dòng
;extension=php_xdebug.dll

Linux: xdebug.ini (ví dụ /etc/php.d/xdebug.ini)
zend_extension_ts=/usr/lib64/php/modules/xdebug.so
Và comment dòng
;extension=xdebug.so

Cơ bản việc dùng DOM xử lý XML,HTML trong PHP

$dom = new domDocument(‘1.0’, ‘utf-8’);
$content = file_get_contents(‘weather.htm’);
$content = mb_convert_encoding($content, ‘HTML-ENTITIES’, “UTF-8”);
@$dom->loadHTML($content);
/*$xpath = new DOMXPath($dom);
$ele = $xpath->query(‘//table’);
echo $ele->item(0)->nodeName;*/
$dom->preserveWhiteSpace = false;

$dom->getElementsByTagName(‘table’);
$dom->getElementById(‘player’);

$ele->parentNode
$ele->childNodes->item(0)
$ele->getAttribute(‘src’);
$ele->nodeValue;
…

Remove empty line and duplicate line (VBS)

//std_format.vbs

Set WshShell = CreateObject (“WScript.Shell”)
If Wscript.arguments.count <> 1 then Wscript.Quit
strFile = Wscript.arguments.Item(0)

Set objSet = CreateObject(“Scripting.Dictionary”)
Set objFSO = CreateObject(“scripting.filesystemobject”)
Set objTS = objFSO.OpenTextFile(strFile)
strFile2 = strFile & “.out”
Set objTS2 = objFSO.OpenTextFile(strFile2, 2, True, -2)

While Not objTS.AtEndOfStream
    strLine = objTS.ReadLine
    If strLine <> “” then
        On Error Resume Next
        Call objSet.Add (strLine, “value”)
        If Err = 0 Then
            objTs2.WriteLine(strLine)
            created = True
        End If
    End if
Wend
objTs.Close
objTs2.Close
Set objTs = Nothing
Set objTs2 = Nothing
objFSO.DeleteFile(strFile)
Call objFSO.MoveFile(strFile2, strFile)
Wscript.Echo “Done”

‘Then: Drag INPUT.DAT – Drop to std_format.vbs