PHP curl_init()

1 개요[ | ]

PHP curl_init()
  • cURL 세션을 초기화하는 PHP 함수

2 예시: 바로 출력[ | ]

a.php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://naver.com");
curl_exec($ch);
curl_close($ch);
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
$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);
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 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}