본문 바로가기

개발/php

[Composer] 설치한 컴포저 업데이트 Window 에서 이미 설치한 Composer의 버전을 확인하고최신 버전으로 업데이트하기 D:\work > composer설치된 Composer의 도움말을 보여준다. D:\work > composer -VComposer version 1.4.1 2017-03-10 09:29:45 D:\work > composer self-updateUpdating to version 1.5.1 (stable channel). Downloading (100%)Use composer self-update --rollback to return to version 1.4.1 D:\work > D:\work > composer -VComposer version 1.5.1 2017-08-09 16:07:22 더보기
date()와 mktime() 활용한 calendar date(format, timestamp)과 mktime(시, 분, 초, 월, 일, 년)을 조합하여 달력 페이지를 만드는데 사용할 수 있다. 주로 사용할 포맷은 date('F') - 월의 완전한 글자 표현 January, March, Octoberdate('Y/m/d') - yyyy/mm/dd 날짜 표현 date('t', mktime(0, 0, 0, $month, 1, $year) - 해당 월의 마지막 날짜 28(29), 30, 31date('w', mktime(0, 0, 0, month, $day, year) - 그 날짜의 요일 숫자 표현. 일요일(0)~토요일(6) 달의 날짜와 앞뒤 빈칸을 포함한 배열을 구하고, 이 배열을 테이블 모양으로 표현하면 된다. // 매월 1일 앞에 빈 칸$repeat_pre.. 더보기
static 배열 요소 참조 Reference to element of static array 레퍼런스를 리턴하는 함수에서 static 배열요소를 리턴하였을 때,리턴값을 받은 변수는 static 배열의 요소를 참조하는가? 아니면 static 배열을 참조하여 해당 요소를 복사한 값을 가지는가? function &func_elm($k, $v) { static $hold = array('alpha'=>0, 'bravo'=>9); if (array_key_exists($k, $hold)) { $hold[$k] += $v; } else { $hold[$k] = 0; } return $hold[$k]; } $omega =& func_elm('omega', 1); print_dump($omega); // 0 func_elm('alpha', 2).. 더보기
배열에서 요소 제거하기 array_splice()unset() array_splice(array &$input, int $offset [, int $length = 0 [, mixed $replacement ]] )주어진 배열에서 offset 값부터 주어진 length 만큼 요소를 삭제한다.주의할 점은 인덱스를 이용하는 게 아니라 offset 으로 처리한다. 일반 배열과 연관 배열(키:값으로 요소 구성)에 모두 적용할 수 있다.일반 배열에서는 적용 후 인덱스가 초기화(0부터 시작) 된다. $target = array('aa', 'bb', 'cc', 'dd', 'ee', 'ff');array_splice($target, 3, 1); array(5) { [0]=> string(2) "aa" [1]=> string(2) "bb" [.. 더보기