URLs
URLs
URL 문자열을 다루다 보면 인코딩하고, 디코딩하고, 파싱해야 할 때가 반드시 생겨요. 이 장은 URL 문자열을 다루는 함수들 — 인코딩·디코딩·파싱 — 을 모아둔 목차예요.
출처: URLs
본문
URL 문자열을 다루는 법을 다루는 장이에요: **인코딩(encoding), 디코딩(decoding), 파싱(parsing)**이 중심이에요.
- 사전 정의 상수(Predefined Constants)
URL 함수(URL Functions)
base64_decode— MIME base64로 인코딩된 데이터를 디코딩해요(Decodes data encoded with MIME base64).base64_encode— 데이터를 MIME base64로 인코딩해요(Encodes data with MIME base64).get_headers— HTTP 요청에 대해 서버가 보낸 모든 헤더를 가져와요(Fetches all the headers sent by the server in response to an HTTP request).get_meta_tags— 파일에서 모든 meta 태그 content 속성을 추출해 배열로 반환해요(Extracts all meta tag content attributes from a file and returns an array).http_build_query— URL 인코딩된 쿼리 문자열을 생성해요(Generate URL-encoded query string).parse_url— URL을 파싱해 구성 요소를 반환해요(Parse a URL and return its components).rawurldecode— URL 인코딩된 문자열을 디코딩해요(Decode URL-encoded strings).rawurlencode— RFC 3986에 따라 URL 인코딩해요(URL-encode according to RFC 3986).urldecode— URL 인코딩된 문자열을 디코딩해요(Decodes URL-encoded string).urlencode— 문자열을 URL 인코딩해요(URL-encodes string).
더 알아보기
urlencode()/rawurlencode()의 차이는 공백을+로 바꾸느냐%20으로 바꾸느냐예요. 폼 데이터와 경로에서 각각 알맞은 것을 골라 써요.parse_url()의 반환 구조를 알면 복잡한 URL에서 필요한 조각만 뽑아 쓰기 쉬워져요.