전체 글
-
php 배열 함수php 2023. 9. 13. 09:08
php에서 배열과 관련된 함수 정리 1. 배열에 대한 정보 얻기 array_key_exists($key, $array)-> 배열에서 키를 확인 (true / false 반환) array_search($value, $array[, $strict])-> 배열에 저장된 값을 검색하고 첫번째 키를 반환, $strict = true 라면 타입까지 일치 in_array($value, $array)-> 배열에 어떤 값이 있는지 확인, (true / false 반환) count($array)-> 배열의 항목 개수를 반환 array_rand($array[, $number])-> 배열에서 랜덤한 항목의 키를 반환, 두 번째 매개변수로 숫자 지정 시, 반환할 키의 갯수 지정 2. 배열을 문자로 변환하고 다시 반대로 변환하기..
-
정규 표현식php 2023. 9. 13. 08:32
php 에서 사용하는 정규식에 대해 간단한게 정리 /lst/-> 문자 lst와 일치 /[abcd]/-> 대괄호 내부 문자중 하나 일치 (여기서는 a,b,c,d 중 하나) /[K-Z]/-> 대괄호 안의 하이픈(-)은 일치시킬 문자의 범위 (K ~ Z 사이의 대문자) /[a-e]/-> a 부터 e 사이의 모든 소문자 일치 /[0-9]/-> 0 부터 9 사이의 모든 숫자와 일치 /[A-z0-9]/-> A 부터 Z 사이의 모든 대소문자 또는 0 부터 9 사이의 모든 숫자와 일치 /^[A-Z]/-> 패턴의 시작 부분에 있는 캐럿(^)은 이러한 문자로 시작해야 한다는 것을 지정 (첫 번째 문자가 A~Z 로 시작해야함) /lst\!$/-> 패턴 끝에 있는 달러($) 는 문자열이 지정된 문자로 끝나야함 (문자열의 마지..
-
CI 프레임워크 활용 (주가스크래퍼)php 2023. 9. 12. 19:39
CI는 PHP 언어를 기반으로 만들어진 프레임워크다. MVC 모델을 기반으로 만들어졌으며, 웹 개발부터 일반적인 개발 까지 PHP를 좀 더 편리하게 이용할 수 있게 구성되어있다. 기존에 제작 중이던 주가 스크래퍼를 CI 프레임워크로 migration 하면서 CI의 구성요소를 공부해보았다. 1. index.php // .htaccess 기본적으로 CI 프레임워크는 index.php를 기준으로 시작한다. index 에서는 $system_path , $application_folder의 위치를 찾아주고 FCPATH , BASEPATH 등의 경로 함수를 선언하는 등의 기본 환경 설정을 하고 본격적으로 core/CodeIgniter.php 를 실행한다. index.php를 기준으로 시작하다보니 특별한 조치가 없다..
-
-
http 헤더 추가하기php 2023. 9. 8. 08:44
header() 함수는 PHP 인터프리터가 브라우저로 보내는 HTTP 헤더를 업데이트 한다. 1. Location members Area Welcome to the members area location 헤더를 사용하면 새로운 URL로 사용자를 보낼 수 있따. PHP 인터프리터가 이후의 PHP 코드를 실행하지 못 하도록 exit 명령어를 사용해야한다. 2. Content-type 대부분의 php 파일은 브라우저로 보낼 html을 생성하지만, php는 json , xml , css와 같은 유형의 파일을 생성하는 데 사용할 수 있다. header('Content-type: application/json'); 3. Cache-Control 브라우저는 사용자가 본 페이지를 캐시(저장)할 수 있다. 만약에 그 페..