본문 바로가기

반응형

Story/php

PHP 5.2 이전 버전에서 json_encode 를 사용하고 싶을때 if (!function_exists('json_encode')) {    function json_encode($data) {        switch ($type = gettype($data)) {            case 'NULL':                return 'null';            case 'boolean':                return ($data ? 'true' : 'false');            case 'integer':            case 'double':            case 'float':                return $data;            case 'string':                return.. 더보기
Alipay의 최신 Error Code 系统错误码 名称 标识 说明 文案(新) 文案(英文) 文案(旧) SYSTEM_EXCEPTION 1000 未知的系统异常 网络系统异常,请稍后再试.(sys_1000) This transaction failed because network system was busy.Please try again later.(sys_1000) 网络系统异常,请稍后再试.(1000) INVALID_PARAMETER 1001 非法参数,主要为入参检查,不符合预期目标 网络系统异常,请稍后再试.(sys_1001) This transaction failed because network system was busy.Please try again later.(sys_1001) 网络系统异常,请稍后再试.(1001) INVALID_INST 1002 非法机构.. 더보기
유튜브 영상 주소에서 영상 아이디 값구하는 정규식 / parse youtube video id using preg_match 유튜브 영상 주소에서 영상 아이디 값구하는 정규식 parse youtube video id using preg_match if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[\w\-?&!#=,;]+/[\w\-?&!#=/,;]+/|(?:v|e(?:mbed)?)/|[\w\-?&!#=,;]*[?&]v=)|youtu\.be/)([\w-]{11})(?:[^\w-]|\Z)%i', $url, $match)) { $video_id = $match[1]; } if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $m.. 더보기
php 에서 PHP_EOL From main/php.h of PHP version 5.5.6: #ifdef PHP_WIN32 # include "tsrm_win32.h" # include "win95nt.h" # ifdef PHP_EXPORTS # define PHPAPI __declspec(dllexport) # else # define PHPAPI __declspec(dllimport) # endif # define PHP_DIR_SEPARATOR '\\' # define PHP_EOL "\r\n" #else # if defined(__GNUC__) && __GNUC__ >= 4 # define PHPAPI __attribute__ ((visibility("default"))) # else # define PHPAPI # en.. 더보기
도로명 주소 api 안전행정부 제공 도로명 주소를 이번에 안전행정부에서 open api 형태로 제공한다. 물론 기존에도 제공을 했었지만 다음과 협업을 통해서 http://postcode.map.daum.net/guide 에서 제공한 이후로 보도자료를 통해 "안전행정부는 최신의 주소 정보를 이용자가 보다 편리하게 활용할 수 있도록 바뀌는 주소정보를 매일 자동으로 제공해 주는 시스템을 구축해 11월부터 시범운영한 뒤 ‘15년부터 전체 민간기업 등으로 서비스를 확대할 계획이다." 라고 소개했다. 홈페이지도 개편이 되고 실제 운영할 시스템이 이 open api 일거란 생각이 들어 이번에 적용하게 되었다. 적용하는 방법을 순서대로 설명하면 http://www.juso.go.kr/addrlink/addrLinkRequestMain.htm?cntcMe.. 더보기
pear 웹에서 설치할때 오류발생시 go-pear.php http://pear.php.net/go-pear 에서 받은 파일로 go-pear.php 실행시 Fatal error: Class 'PEAR' not found in 경로 go-pear.php on line 697 이런 에러 발생시 해결방법 $bootstrap_files = array( 'PEAR5.php' => 'https://raw.github.com/pear/pear-core/master/PEAR5.php', 'PEAR.php' => 'https://raw.github.com/pear/pear-core/master/PEAR.php', 'Archive/Tar.php' => 'https://raw.github.com/pear/Archive_Tar/master/Archive/Tar... 더보기
PHP, cURL, CURLOPT FOLLOWLOCATION and Open Basedir or Safe Mode PHP, cURL, CURLOPT FOLLOWLOCATION and Open Basedir or Safe Mode php cURL 을 이용해서 rss feed 를 가져오는경우 $ch = curl_init($url); curl_setopt( $ch, CURLOPT_POST, false ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true ); curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7" ); curl_setopt( $ch, CURLOPT_HEADER, false ); curl_setopt( .. 더보기
php ini 변경없이 session 시간 늘리기 SESSION을 핸들링하려면 SESSION 이 저장되는 디렉토리를 별도로 사용해야 한다. $sessdir = $_SERVER['DOCUMENT_ROOT']."/저장디렉토리"; ini_set('session.save_path', $sessdir); session_save_path($sessdir); ini_set("session.cache_expire", 180); // 세션 유효시간 : 분 더보기
SPAW Editor ie11 에서 동작하지 않는 문제점 SPAW Editor ie11 에서 에디터가 나타나지 않고 textarea 로 노출이된다. 이 문제를 해결하고자 구글링을 하다가 http://www.ziplineinteractive.com/blog/spaw-editor-not-loading-content-in-ie9-bug-fix/ 이 문서를 찾았는대 아래 댓글중에서 아래 내용을 찾을수있었다. 이 util.class.php 파일을 /class 에 덮어씌워주면 해결이 된다. 출처 : http://geigenberger.wordpress.com/2013/11/01/spaw-2-von-solmetra-internet-explorer-11-fix/ for IE, I found the solution from http://geigenberger.wordpress.. 더보기
php 5.3 변경사항 preg_replace , preg_replace_callback PHP 5.3. 부터 POSIX Regex 함수( ereg_replace, ereg, eregi_replace, eregi, split, spliti, sql_regcase ) 들이 중요도가 떨어져서 더이상 사용하지 않게될 함수로 되었습니다. (This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.) PHP 6.0.0 부터 완전히 제거됩니다. http://php.net/manual/en/reference.pcre.pattern.posix.php Function replacements POSIX PCRE ereg_replace() preg_replace() ereg() preg_match.. 더보기

반응형