1 개요[ | ]
- PHP curl_init()
- cURL 세션을 초기화하는 PHP 함수
2 예시: 바로 출력[ | ]
a.php
PHP
Copy
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://naver.com");
curl_exec($ch);
curl_close($ch);
Console
Copy
root@localhost:~# php a.php
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center> NWS </center>
</body>
</html>
3 예시: 변수에 담기[ | ]
b.php
PHP
Copy
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://naver.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
Console
Copy
root@localhost:~# php b.php
string(162) "<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center> NWS </center>
</body>
</html>
"
4 같이 보기[ | ]
- PHP curl_close() - cURL 세션 닫기
- PHP curl_setopt() - cURL 전송 옵션 설정
- PHP curl_multi_init() - 새로운 cURL 다중핸들 반환
5 참고[ | ]
편집자 Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.