반응형
반응형
반응형

 

$ cd path/to/your/php/code

$ php -S localhost:8000

 

반응형

'프로그래밍 > PHP' 카테고리의 다른 글

이모지 제거.  (0) 2017.01.09
세션 관리. session id 가 계속 갱신되는 문제.  (0) 2016.03.10
[error] date_default_timezone_set()  (0) 2012.12.11
short_open_tag 설정.  (0) 2012.08.07
파일 업로드.  (0) 2012.07.11
반응형



[펌] http://seongtak-yoon.tistory.com/19



MySQL 5.0과 같이 저버전을 사용하게되면, 요즘 스마트폰에 기본으로 적용된 Emoji 문자때문에 골치 아픈 경우가 많습니다.

MySQL은 기본적으로 UTF-8이 3Byte까지만 지원하기때문에 4Byte로 구성된 Emoji와 같은 문자가 저장되면 빈 값으로 저장되거나 ?? 등으로 저장됩니다.

이를 방지하기 위해서 (정확이는 utf8mb4 타입을 적용하기 전까지 임시방편으로 ..) 저장되지 않도록 애플리케이션단에서 제거할 필요가 있습니다.


# planes 1-3

# planes 4-15

# plane 16

preg_replace("/\xF0[\x90-\xBF][\x80-\xBF]{2} | [\xF1-\xF3][\x80-\xBF]{3} | \xF4[\x80-\x8F][\x80-\xBF]{2}/", "", $string);



참고된 테이블 구성 그대로 정규식으로 조합하여 4Byte UTF-8 문자를 찾아내어 ""(빈값)으로 replace합니다.


4Byte UTF-8의 first Byte는 F0~F4로 구성되어 있습니다.

 - http://docs.oracle.com/cd/E24693_01/server.11203/e10729/appunicode.htm#CACHBDGH   여기를 참고해보시면  

 - 이 정보는 1~3Byte와 중복되지 않는 값으로 일종의 Key값(?)으로 생각하면 될것 같네요.



💞💞허허허💞💞 -> 허허허가 됩니다.

⛄허허 -> ⛄허허가 됩니다. 

이 문자는 3Byte로 구성된 UTF-8로 없어지지 않는 것이 맞고, 저버전 MySQL도 문제없이 처리가능합니다.

- http://apps.timwhitlock.info/unicode/inspect?s=%E2%9B%84



참고 사이트


- 특정 문자 구성내용 보기 

http://apps.timwhitlock.info/unicode/inspect?s=%F0%9F%92%9E


- UTF-8 구성표

http://www.utf8-chartable.de/unicode-utf8-table.pl


- 도움되는 사이트.

http://stackoverflow.com/questions/16496554/can-php-detect-4-byte-encoded-utf8-chars


- getEmoji

http://getemoji.com/



반응형

'프로그래밍 > PHP' 카테고리의 다른 글

php 서버 바로 띄우기.  (0) 2020.06.03
세션 관리. session id 가 계속 갱신되는 문제.  (0) 2016.03.10
[error] date_default_timezone_set()  (0) 2012.12.11
short_open_tag 설정.  (0) 2012.08.07
파일 업로드.  (0) 2012.07.11
반응형

PHP 에서 세션 관리.


특이 사항 : 80 port 가 아닌 다른 port 를 사용할 경우...


<?


// www.sample.com:10000

$host = $_SERVER["HTTP_HOST"];


session_save_path("/home/user/sample/session_data");

session_set_cookie_params(0, "/");


ini_set("session.cookie_domain", $host);


session_start();


echo session_id();


?>


위와 같이 하면 session id 가 페이지 갱신될때마다 바뀐다.

그래서 세션 관리가 전혀 안된다.

한참을 찾아 헤맨결과.....


여기가 문제였다!!!!!!!

ini_set("session.cookie_domain", $host);

 - port 정보가 들어가서 그런듯....... 도메인 정보만 들어가야 하는듯...


아래와 같이 수정하면 잘 된다.

// www.sample.com

$domain = $_SERVER["SERVER_NAME"];

ini_set("session.cookie_domain", $domain);





반응형

'프로그래밍 > PHP' 카테고리의 다른 글

php 서버 바로 띄우기.  (0) 2020.06.03
이모지 제거.  (0) 2017.01.09
[error] date_default_timezone_set()  (0) 2012.12.11
short_open_tag 설정.  (0) 2012.08.07
파일 업로드.  (0) 2012.07.11
반응형

 

Warning: date() [function.date]: 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/Seoul' for 'KST/9.0/no DST' instead

php.ini 편집

 - date.timezone = Asia/Seoul

 

이후 apache 재 구동.

반응형

'프로그래밍 > PHP' 카테고리의 다른 글

이모지 제거.  (0) 2017.01.09
세션 관리. session id 가 계속 갱신되는 문제.  (0) 2016.03.10
short_open_tag 설정.  (0) 2012.08.07
파일 업로드.  (0) 2012.07.11
[Oracle] BLOB insert 하기  (0) 2009.02.11
반응형


php.ini 설정

 - short_open_tag = On



php open tag 기본 = <?php 이다.

<? 로도 open 가능하게 하는 설정함.

반응형

'프로그래밍 > PHP' 카테고리의 다른 글

세션 관리. session id 가 계속 갱신되는 문제.  (0) 2016.03.10
[error] date_default_timezone_set()  (0) 2012.12.11
파일 업로드.  (0) 2012.07.11
[Oracle] BLOB insert 하기  (0) 2009.02.11
한글 사용할때 헤더  (0) 2009.02.11
반응형

 

        $upload_file_form_name = "upload_file";

        $upload_file_save_dir = "upload/";
        if($_FILES[$upload_file_form_name]["error"] > 0) {
                echo "Error: " . $_FILES[$upload_file_form_name]["error"] . "<br />";
        } else {
                echo "Upload: " . $_FILES[$upload_file_form_name]["name"] . "<br />";
                echo "Type: " . $_FILES[$upload_file_form_name]["type"] . "<br />";
                echo "Size: " . ($_FILES[$upload_file_form_name]["size"] / 1024) . " Kb<br />";
                echo "Stored in: " . $_FILES[$upload_file_form_name]["tmp_name"];

 

                $upload_file_name = $upload_file_save_dir . $_FILES[$upload_file_form_name]["name"];
                if (file_exists($upload_file_name)) {
                        echo $_FILES[$upload_file_form_name]["name"] . " already exists. ";
                } else {
                        move_uploaded_file($_FILES[$upload_file_form_name]["tmp_name"], $upload_file_name);
                        echo "Stored in: " . $upload_file_name;
                }
        }

반응형

'프로그래밍 > PHP' 카테고리의 다른 글

[error] date_default_timezone_set()  (0) 2012.12.11
short_open_tag 설정.  (0) 2012.08.07
[Oracle] BLOB insert 하기  (0) 2009.02.11
한글 사용할때 헤더  (0) 2009.02.11
한글 자르기  (0) 2009.02.11
반응형
$conn = OCILogon("", "");
    $lob = OCINewDescriptor($conn, OCI_D_LOB);
    $stmt=OCIParse($conn,"insert into UPLOAD_TEST (COLUMN1, COLUMN2) values (1, EMPTY_BLOB()) returning COLUMN2 into :BLOBDATA");

    OCIBindByName($stmt, ':BLOBDATA', $lob, -1, OCI_B_BLOB);
    OCIExecute($stmt, OCI_DEFAULT);

    if($lob->savefile($_FILES[lob_upload][tmp_name]))
    {
        OCICommit($conn);
        //echo "Blob successfully uploaded\n";
    }
    else
    {
        //echo "Couldn't upload Blob\n";
        OCIRollback($conn);
    }

    OCIFreeDesc($lob);
    OCIFreeStatement($stmt);
    OCILogoff($conn);


반응형

'프로그래밍 > PHP' 카테고리의 다른 글

short_open_tag 설정.  (0) 2012.08.07
파일 업로드.  (0) 2012.07.11
한글 사용할때 헤더  (0) 2009.02.11
한글 자르기  (0) 2009.02.11
페이지 구하기  (0) 2009.02.11
반응형
@header("Expires: 0");
@header("Cache-Control: no-cache, must-revalidate");
@header("Pragma: no-cache");
header("Content-type: text/html; charset=euc-kr");
반응형

'프로그래밍 > PHP' 카테고리의 다른 글

파일 업로드.  (0) 2012.07.11
[Oracle] BLOB insert 하기  (0) 2009.02.11
한글 자르기  (0) 2009.02.11
페이지 구하기  (0) 2009.02.11
파일 크기 구하기(단위별)  (0) 2009.02.11
반응형

// 한글 길이 자르기.
function han_substr($string, $limit_length)
{
    $string_length = strlen( $string );
    if( $limit_length > $string_length ) return $string;
    else
    {
        $string = substr( $string, 0, $limit_length );
        $han_char = 0;
        for($i = $limit_length - 1; $i >= 0; $i--)
        {
            $lastword = ord(substr($string, $i, 1)); //뒤에서 한글자씩 떼어서
            if(127 > $lastword) break; //정상적인 영문자,숫자라면..stop
            else $han_char++; //한글 or 특수문자라면..
        }
 
        //짝이 안맞으므로 한글자 더 작게 자른다.
        if($han_char%2 == 1) $string = substr( $string, 0, $limit_length-1 );
        return ($string."...");
    }
}
반응형

'프로그래밍 > PHP' 카테고리의 다른 글

[Oracle] BLOB insert 하기  (0) 2009.02.11
한글 사용할때 헤더  (0) 2009.02.11
페이지 구하기  (0) 2009.02.11
파일 크기 구하기(단위별)  (0) 2009.02.11
form 에서 method get 안될때..  (0) 2009.02.11
반응형
<style>
.pageNumStyleTB TD {padding-bottom:3px;}
.pageNumStyle_Sel , .pageNumStyle_Out , .pageNumStyle_Over {width:30px; font:bold 9pt Verdana; text-align:center;}
.pageNumStyle_Sel {color:#CC6600;}
.pageNumStyle_Out {cursor:pointer; background-color:#FFFFFF; color:#0A87D1;}
.pageNumStyle_Over {cursor:pointer; background-color:#F5F2E7; color:#0A87D1; text-decoration:underline;}
.pageInfo1 {text-align:left; background-color:#f2f2f2; font-size:12px; padding:5 5 5 40px}
</style>




// 현재 페이지.
        if(!$c_page) $c_page = 1;
 
        // 한번에 20개의 list 출력.
        $view_list = 20;
        $total_row = 총 row 의 수.
        $start_limit = ($c_page - 1) * $view_list;
        $limit_qry = "LIMIT $start_limit, $view_list";

<table border="0" cellpadding="0" cellspacing="0" class="pageNumStyleTB" align="center" style="margin:20px 2px 3px 2px;">
<tr>

<?
    // 총 페이지 번호 수 - 올림함수.
    $total_page = ceil($total_row / $view_list);
 
    // c_page, view_list(한페이지에 20개씩)
    // 한번에 5개의 페이지번호  출력.
    $view_page = 5;
 
    // 출력할 시작 페이지번호  ~ 끝 페이지번호 .
    $print_start_page = (ceil($c_page / $view_page) -1) * $view_page + 1;
    $print_end_page = ceil($c_page / $view_page) * $view_page;
    if($print_end_page > $total_page) $print_end_page = $total_page;
 
    // 페이지 링클 걸때 필요한 form 파라미터.
    $link_parameter = "search_mode=$search_mode&search_word=$search_word&id=$id";
 
    // 이전 5페이지 - 화살표.
    if($print_start_page > 1)
    {
        $pre_end_page = $print_start_page - 1;
        echo "<td width=\"20\" align=\"center\" style=\"font:8pt 돋움;padding-top:2px;color:#999999;\"><a href='$PHP_SELF?c_page=$pre_end_page&$link_parameter'>◀</a></td>";
    }
// 5페이지 출력.
    for($i = $print_start_page; $i <= $print_end_page; $i++)
    {
        if($i == $c_page) echo "<td class=\"pageNumStyle_Sel\">$i</td>";
        else echo "<td =\"location.href='$PHP_SELF?c_page=$i&$link_parameter'\" =\"this.className = 'pageNumStyle_Over'\" =\"this.className = 'pageNumStyle_Out'\" class=\"pageNumStyle_Out\">$i</td>";
 
        if($i != $print_end_page) echo "<td width=\"1\"><img src=\"http://icons.com.ne.kr/trandot.gif\" height=\"15\" width=\"1\" style=\"background-color:#CCCCCC;\"></td>";
    }
 
    // 이후 5페이지 - 화살표.
    if($total_page > $print_end_page) echo "<td width=\"20\" align=\"center\" style=\"font:8pt 돋움;padding-top:2px;color:#999999;\"><a href='$PHP_SELF?c_page=$i&$link_parameter'>▶</a></td>";

?>
</tr>
</table>

반응형

'프로그래밍 > PHP' 카테고리의 다른 글

한글 사용할때 헤더  (0) 2009.02.11
한글 자르기  (0) 2009.02.11
파일 크기 구하기(단위별)  (0) 2009.02.11
form 에서 method get 안될때..  (0) 2009.02.11
require 와 include 의 차이점  (0) 2009.02.06

+ Recent posts