Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- zsh
- typescript
- border-width
- angular5
- fromEvent
- Ionic
- aab 배포
- 이미지바꾸기
- getElementsByClassName
- sealize
- Visual Studio Code
- change detection
- hashchange
- rxjs
- NVM
- Sentry
- VSCode
- error
- 변화감지
- 테두리굵기
- JavaScript
- ChangeDetectorRef
- code .
- oh-my-zsh
- Git
- ion-range
- IONIC3
- angular
- 자바스크립개념
- php
Archives
- Today
- Total
hsunny study blog
쿼리스트링 형식을 변수로 인식하는 parse_str() 본문
parse_str ( string $encoded_string [, array &$result ] ) : void
parse_str의 파라미터를 1개만 사용할 수도 있고, 2개를 사용할 수도 있습니다.
더보기
공식문서
www.php.net/manual/en/function.parse-str.php
PHP: parse_str - Manual
I wrote a pair of functions using parse_str() that will write values in an array to a textfile and vice versa, read those values from the textfile back into the array. Quite useful if you need to store lots of data but don't have access to SQL.Save the arr
www.php.net
사용 예
인자 1개만 사용한다면, a=b&c=d일 경우, 각 변수의 이름은 a,c가 되고 차례로 b, c가 할당됩니다.
<?php
// $p = 'name=sunny&tel=12345678'
parse_str($p);
echo "name: " . $name; // name: sunny
echo "tel: " . $tel; // tel: 12345678
|
인자 2개를 모두 사용한다면, 2번째에 넣은 이름대로 파싱한 $p의 데이터가 들어갑니다.
<?php
// $p = 'name=sunny&tel=12345678'
parse_str($p, $input);
echo "name: ". $input['name']; // name: sunny
|
Changelog
7.2.0 버전부터 2번째 파라미터를 사용하지 않는다면 E_DEPRECATED notice를 방출합니다.
기타
쿼리스트링 형식
- 데이터를 전달하기 위한 URL의 일부분
- GET 방식 파라미터 전달 문자열
- ? 다음 부분
- 변수=값&변수=값&변수=값 ... 의 형식
'programming > PHP' 카테고리의 다른 글
apachectl (0) | 2021.03.07 |
---|---|
PDO 적용기 (0) | 2020.12.27 |
전화번호 정규식 (0) | 2020.08.31 |
-> 와 =>의 차이점 (0) | 2019.07.28 |
배열을 하나의 문자열로 만드는 함수 (0) | 2019.07.21 |