PIXNET Logo登入

Felix's Second Life 電腦數碼世界

跳到主文



部落格全站分類:數位生活

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 10月 18 週六 201410:18
  • 解決 PHP/mySQL 資料庫讀取中文顯示亂碼或問號

解決 PHP/mySQL 資料庫讀取中文顯示亂碼或問號

發佈時間: 2011-01-09 週日

(繼續閱讀...)
文章標籤

Felix 發表在 痞客邦 留言(0) 人氣(708)

  • 個人分類:php
▲top
  • 8月 24 週日 201413:44
  • PHP模板引擎原理


 開發一個web項目,通常分為兩部分,一部分是GUI,即界面、美工,使用HTML,CSS,JS編寫,另一部分則是業務邏輯,即程序、功能,使用PHP編寫。而模板引擎則是聯繫這兩部分的「橋樑」,可理解成一個PHP類,裡面定義了許多方法,實現了將PHP的原始輸出加載上界面樣式後再輸出。
(繼續閱讀...)
文章標籤

Felix 發表在 痞客邦 留言(0) 人氣(2,104)

  • 個人分類:php
▲top
  • 2月 19 週三 201408:32
  • php fopen download file 下載檔案

<?php
$content = "";
$fp = fopen("http://file-to-download.com/a-file.zip", "rb");

if (!$fp)
die("Error opening file.");
while (!feof($fp))
$content .= fread($fp, 2048);
fclose($fp);

$fp=fopen("local-file-name.zip", "w");
fwrite($fp, $content);
fclose($fp);
?>
(繼續閱讀...)
文章標籤

Felix 發表在 痞客邦 留言(0) 人氣(431)

  • 個人分類:php
▲top
  • 2月 17 週一 201420:41
  • 在 php 使用 at 命令 增加排程

首先要講下 at 命令 是要用 /bin/bash shell 來執行的,
你可以在php裡查一下 apache 使用的是哪個 shell,
<?

$output = shell_exec('echo $SHELL');
echo $output;
?>
centos 預設 apache 的 shell 是 /bin/nologin
在linux 裡改
usermod -s /bin/bash apache
這樣就可以apache 就可以使用 at 了
由於at指令不同其他,不能用shell_exec執行,所以用以下方法
<?
php
$r
= popen('/usr/bin/at noon',"w");
fwrite
($r,"ls -l");
pclose
($r);
?>
搞定
(繼續閱讀...)
文章標籤

Felix 發表在 痞客邦 留言(0) 人氣(482)

  • 個人分類:php
▲top
  • 2月 16 週日 201413:27
  • move_uploaded_file gives “failed to open stream: Permission denied ” error

 

This is because images and tmp_file_upload are only writable by root user. For upload to work we need to make the owner of those folders same as httpd process owner OR make them globally writable (bad practice).

  • Check apache process owner:  ps aux | grep httpd. The first column will be the owner typically it will be nobody


  • Change the owner of images and tmp_file_upload to be become nobody or whatever the owner you found in step 1.


    $sudo chown nobody /var/www/html/mysite/images/


    $sudo chown nobody /var/www/html/mysite/tmp_file_upload/




  • Chmod images and tmp_file_upload now to be writable by the owner, if needed [Seems you already have this in place]. Mentioned in @Dmitry Teplyakov answer.


    $ sudo chmod -R 0755 /var/www/html/mysite/images/


    $ sudo chmod -R 0755 /var/www/html/mysite/tmp_file_upload/




  • For more details why this behavior happend, check the manual http://php.net/manual/en/ini.core.php#ini.upload-tmp-dir , note that it also talking about open_basedir directive.



  • (繼續閱讀...)
    文章標籤

    Felix 發表在 痞客邦 留言(0) 人氣(117)

    • 個人分類:php
    ▲top
    • 2月 16 週日 201408:31
    • php 上傳多個檔案


    上傳多個檔案
    可以對 input 功能變數使用不同的 name 來上傳多個檔案。
    PHP 支援同時上傳多個檔案並將它們的訊息自動以陣列的形式組織。要完成這項功能,需要在 HTML 表單中對檔案上傳功能變數使用和多選框與復選框相同的陣列式送出語法。


    注: 對多檔案上傳的支援是在 PHP 3.0.10 版本增加的。




     





    例子 38-4. 上傳多個檔案









    <form action="file-upload.php" method="post" enctype="multipart/form-data">
    Send these files:<br />
    <input name="userfile[]" type="file" /><br />
    <input name="userfile[]" type="file" /><br />
    <input type="submit" value="Send files" />
    </form>







    當以上表單被送出後,陣列 $_FILES['userfile'],$_FILES['userfile']['name'] 和 $_FILES['userfile']['size'] 將被起始化(在 PHP 4.1.0 以前版本是 $HTTP_POST_FILES)。若果 register_globals 的設定為 on,則和檔案上傳關聯的全局變量也將被起始化。所有這些送出的訊息都將被儲存到以數字為索引的陣列中。
    例如,假設名為 /home/test/review.html 和 /home/test/xwp.out 的檔案被送出,則 $_FILES['userfile']['name'][0] 的值將是 review.html,而 $_FILES['userfile']['name'][1] 的值將是 xwp.out。類似的,$_FILES['userfile']['size'][0] 將包括檔案 review.html 的大小,依此類推。
    此外也同時設定了 $_FILES['userfile']['name'][0],$_FILES['userfile']['tmp_name'][0],$_FILES['userfile']['size'][0] 以及 $_FILES['userfile']['type'][0]。   
    (繼續閱讀...)
    文章標籤

    Felix 發表在 痞客邦 留言(0) 人氣(2,288)

    • 個人分類:php
    ▲top
    • 2月 09 週日 201419:00
    • php 遞歸 問題

    一開始這樣寫,但出問題
    function trim_dom_node($string){
    $string=str_replace(" <","<",$string,$count);
    echo "com  ";
    if($count >= 1)
    {
        trim_dom_node($string);
    }
    else {return str_replace("\n<","<",$string);}
    }
    (繼續閱讀...)
    文章標籤

    Felix 發表在 痞客邦 留言(0) 人氣(17)

    • 個人分類:php
    ▲top
    • 2月 04 週二 201415:20
    • php 回覆 xml 格式 資料

    <?
    header("Content-Type:text/xml");
    echo "<
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
    <g2sResponse xmlns="http://www.gamingstandards.com/wsdl/g2s/v1.0">&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
    &lt;g2s:g2sMessage xmlns:g2s="http://www.gamingstandards.com/g2s/schemas/v1.0.3"&gt;
    &lt;g2s:g2sAck g2s:dateTimeSent="'.time_xml().'" g2s:egmId="RBG_1234"
    g2s:hostId="2"/&gt;
    &lt;/g2s:g2sMessage&gt;</g2sResponse>
    </soap:Body>
    </soap:Envelope>
    (繼續閱讀...)
    文章標籤

    Felix 發表在 痞客邦 留言(0) 人氣(254)

    • 個人分類:php
    ▲top
    • 2月 03 週一 201415:20
    • PHP 物件導向 設計 Build seven good object-oriented habits in PHP

    In the early days of PHP programming, PHP code was limited to being procedural in nature. Procedural codeis characterized by the use of procedures for the building blocks of the application. Procedures offer a certain level of reuse by allowing procedures to be called by other procedures.
    However, without object-oriented language constructs, a programmer can still introduce OO characteristics into PHP code. It's a tad more difficult and can make the code more difficult to read because it's mixing paradigms (procedural language with pseudo-OO design). OO constructs in PHP code — such as the ability to define and use classes, the ability to build relationships between classes that use inheritance, and the ability to define interfaces — make it much easier to build code that adheres to good OO practices.
    While purely procedural designs without much modularity run just fine, the advantages of OO design show up in the maintenance. Because a typical application will spend the bulk of its lifetime in maintenance, code maintenance is a large expense over the lifetime of an application. It can also be easily forgotten during development. If you're in a race to get your application developed and deployed, long-term maintainability can take a back seat to getting something to work.
    (繼續閱讀...)
    文章標籤

    Felix 發表在 痞客邦 留言(0) 人氣(39)

    • 個人分類:php
    ▲top
    • 2月 02 週日 201418:58
    • php function 參數 數目 可變















    <?php function foo() {

    $numargs = func_num_args(); if ($numargs > 2) {

    echo "First: ". func_get_arg(0). "\n";

    echo "Second: ". func_get_arg(1). "\n";

    echo "Third: ". func_get_arg(2). "\n";

    } return $numargs;

    }
    $n = foo (10, 15, 20); //傳入 3 個參數 echo $n; ?>














    (繼續閱讀...)
    文章標籤

    Felix 發表在 痞客邦 留言(0) 人氣(97)

    • 個人分類:php
    ▲top
    12»

    參觀人氣

    • 本日人氣:
    • 累積人氣:

    熱門文章

    • (3,986)批量txt 繁簡轉換 ConvertZ v8.02 多国语言版
    • (51,911)mhdd中文說明完整版
    • (212)什么是注册商标标记“TM”代表什么意思?
    • (3,336)Symantec Ghost Solution Suite v2.0(Ghost 企業版)
    • (803)fcitx配置 说明文档(中文PDF文档)
    • (11,596)[XF]完全解說 Intel® Extreme Memory Profiles (XMP)
    • (7,278)WinAVI Video Converter 9.0 繁體免安裝
    • (26,428)賭場實用英語教學!
    • (1,684)Your Uninstaller! 2008 PRO v6.1.1236 免安裝破解版
    • (13,637)按鍵精靈(QMacro)6.71 綠色免安裝破解簡體版

    AdSense Search BLOG 內文

    標題搜尋

    文章分類

    • Raspberry Pi (1)
    • postgresql (1)
    • 數據分析 (1)
    • 網絡安全 (6)
    • windows server (5)
    • Android 開發 (30)
    • HTML5 (7)
    • Esxi 5.1 (4)
    • 手機 (16)
    • MySQL (2)
    • Java (5)
    • php (18)
    • 網頁相關 (29)
    • windows 光碟制定、封裝 (14)
    • 網路文學 (8)
    • Economics (42)
    • Linux (86)
    • c++ (19)
    • Software for Windows (76)
    • 電腦雜項 (86)
    • 生活瑣事 (5)
    • Microsoft (52)
    • 未分類文章 (1)

    clustrMaps

    pixnet

    pixGoogleAdsense1

    pixGoogleAdsense2