PHP


    (Page 1 of 9)   
    « Prev
      
    1
      2  3  4  5  Next »

    PHP 5.3.x 的 strtotime() 時區設定 警告訊息修正

    Debian Linux 使用 testing 的話, 若於上星期有做過 dist-upgrade 的話, 就會發現 PHP 已經被升級到 5.3.1-5, 而且出現一堆警告訊息.

    我遇到的有下面這三種錯誤訊息:

    1. PHP Warning:  strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST' instead in /tmp/a.php
    • Full Story
    • Share
    • Podcast

    PHP 免費線上電子書 - Practical PHP Programming

    PHP 免費的線上電子書, 這本應該不算是入門, 比較偏中上程度適合閱讀, 裡面也有提到如何寫 PHP extensions 的 Hello world 版.
    • Full Story
    • Share
    • Podcast

    PHP 將 UTF-8 的 字串 依 指定長度 切割成陣列(str_split 的 UTF-8版)

    PHP 的 str_split() 的功能、使用方式 如下:
    <?php
    $str = 'Hello';
    print_r(str_split($str)); // array('H', 'e', 'l', 'l', 'o')
    print_r(str_split($str, 3)); // array('Hel', 'lo')
    ?>

    str_split() 可以將 字串 依 需要的長度 做分割, 但是對 UTF-8 的中文, 就無法切依需要的長度來做切割, 要自己另外處理.

    • Full Story
    • Share
    • Podcast

    PHP 可連接多個 "->" 來連續處理、執行 的 物件寫法

    物件(Object) 在撰寫時, 會希望 於使用、操作上, 可以更直覺化(擴充性... 等等, 不是此篇重點.), 下述的寫法就很常見.
    • $db->select('*')->limit(10)->begin(0) ... 等等. (在操作上(Method), 可以一直 "->" 的操作下去.)
    • 執行順序:
      1. select('*')
      2. limit(10)
      3. begin(0)
    • Full Story
    • Share
    • Podcast

    会汉语就会编,专业php中文编程工具 phpcn 4.2 真正的php中文开发工具

    会汉语就会编,专业php中文编程工具,真正的php中文开发工具,连php函数都是中文

    V4.2版 更新说明

    1、修正了4.0版的错误

    2、更新了远程PHP调试功能
    (该功能可在没有装php服务器的机器上直接调试php程序)

    3、更正了会修改首页的bug,现在绝不会修改首页了。

    4、本版本是目前功能最完善,最稳定的版本

    15:31 2010-1-2

    V4.0版 更新说明

    1、启动最大化窗口

    2、增加调试出错自动跳转到出错行。

    • Full Story
    • Share
    • Podcast

    PHP 指定 字型 將 文字 畫成圖片

    PHP 指定字型, 並將文字畫成圖片來顯示.

    範例程式

    使用字型: /usr/share/fonts/truetype/arphic/bkai00mp.ttf

    下述程式會產生 800 x 600 的圖片, 用 bkai00mp.ttf 來將 "今天天氣真好\n是旅遊的好天氣" 的 text 內容, 變成圖片.

    • Full Story
    • Share
    • Podcast

    PHP 使用 SimpleXML 來解析 XML 內容、屬性

    PHP 可以使用 simplexml_load_stringsimplexml_load_file 來解析 XML, 以取得內容.

    程式 與 XML 內容

    <?php
    $string = <<<XML
    <?xml version='1.0'?>
    <document responsecode="200">
      <result count="10" start="0" totalhits="133047950">
        <title>Test</title>
        <from>Jon</from>
        <to>Tsung</to>
      </result>
    </document>
    XML;
     
    $xml = simplexml_load_string($string);
    print_r($xml);
    ?>
    • Full Story
    • Share
    • Podcast

    PHP 使用 CURL 同步抓取多個網頁

    一般 CURL 抓網頁的方法, 是一頁一頁抓, 假設要抓 4頁, 所費時間各別是 5,10,7,5 秒, 那全部總合所花的時間就是 5 + 10 + 7 + 5 = 27 秒.

    若能同時間去抓取多個網頁, 所花費的時間 5,10,7,5 秒, 全部總合所花的時間是 10 秒.(花費最多時間的秒數)

    • Full Story
    • Share
    • Podcast

    PHP 的 array_slice 保留 key 的值

    PHP 使用 array_slice 取得某區間的 array 值, 但是 key 的值如果是數字, 則會被修改成 0, 1... 等.

    範例

    <?php
    $alist = array(
        '2009' => '11',
        '聖誕節' => '22',
        '2098' => '11',
        '111a' => '33',
    );

    $output = array_slice($alist, 0, 2);
    print_r($output);
    ?>
    • Full Story
    • Share
    • Podcast

    PHP 的 array merge 保留 key 的值

    PHP 的 array_merge 會將 數值 變成 0, 1, 2..., 就算是強制轉換成字串也一樣.

    範例 - 使用 array_merge

    <?php
    $a1 = array(
        '9' => '0',
        '311' => '1',
        '快樂' => '2',
        '2009a' => '3');

    $a2 = array(
        '2009' => '11',
        '聖誕節' => '22',
        '111a' => '33');

    $amerge = array();

    $amerge = array_merge($a1, $a2);

    print_r($amerge);
    ?>
    • Full Story
    • Share
    • Podcast
    (Page 1 of 9)   
    « Prev
      
    1
      2  3  4  5  Next »

    No popular authors found.

    Latest I.T. Jobs


      

    RSS

    I.T. Blogs - 香港矽谷

    [ +more Syndicate]

    ↑ Top of the page