English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP 기본 튜토리얼

PHP 고급 튜토리얼

PHP & MySQL

PHP 참조 매뉴얼

PHP curl_escape() 함수 사용법 및 예제

PHP CURL 참조 매뉴얼

(PHP 5 >= 5.5.0)

curl_escape — 주어진 문자열을 URL 인코딩합니다.

문법

string curl_escape ( resource $ch , string $str )

이 함수는 주어진 문자열을 URL 인코딩합니다.

파라미터

ch

curl_init()로 반환된 CURL 핸들

str

인코딩된 문자열

반환 값

인코딩된 문자열을 반환하거나 실패시 FALSE를 반환합니다.

온라인 예제

<?php
// CURL 핸들을 생성합니다
$ch = curl_init();
// GET 파라미터를 인코딩합니다
$location = curl_escape($ch, 'Hofbräuhaus / München');
// 결과: Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen
// URL을编码한 비교
$url = "http://example.com/add_location.php?location={$location}";
// 결과: http://example.com/add_location.php?location=Hofbr%C3%A4uhaus%20%2F%20M%C3%BCnchen
// HTTP 요청을 보내고 핸들을 닫습니다
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
?>

PHP CURL 참조 매뉴얼