本文整理汇总了PHP中curl_cli_server_start函数的典型用法代码示例。如果您正苦于以下问题:PHP curl_cli_server_start函数的具体用法?PHP curl_cli_server_start怎么用?PHP curl_cli_server_start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了curl_cli_server_start函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkForClosedFilePointer
function checkForClosedFilePointer($curl_option, $description)
{
$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');
$ch1 = curl_init();
$ch2 = curl_init();
$options = array(CURLOPT_RETURNTRANSFER => 1, $curl_option => $fp, CURLOPT_URL => curl_cli_server_start());
// we also need to set CURLOPT_VERBOSE to test CURLOPT_STDERR properly
if (CURLOPT_STDERR == $curl_option) {
$options[CURLOPT_VERBOSE] = 1;
}
if (CURLOPT_INFILE == $curl_option) {
$options[CURLOPT_UPLOAD] = 1;
}
curl_setopt_array($ch1, $options);
curl_setopt_array($ch2, $options);
fclose($fp);
// <-- premature close of $fp caused a crash!
$mh = curl_multi_init();
curl_multi_add_handle($mh, $ch1);
curl_multi_add_handle($mh, $ch2);
$active = 0;
do {
curl_multi_exec($mh, $active);
} while ($active > 0);
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);
echo "Ok for {$description}\n";
}
示例2: curl_cli_server_start
<?php
/*
* Prototype: bool curl_setopt_array(resource $ch, array $options)
* Description: Sets multiple options for a cURL session.
* Source: ext/curl/interface.c
* Documentation: http://wiki.php.net/qa/temp/ext/curl
*/
// Figure out what handler to use
include 'server.inc';
$host = curl_cli_server_start();
if (!empty($host)) {
// Use the set Environment variable
$url = "{$host}/get.php?test=get";
} else {
// Create a temporary file for the test
$tempname = tempnam(sys_get_temp_dir(), 'CURL_HANDLE');
$url = 'file://' . $tempname;
// add the test data to the file
file_put_contents($tempname, "Hello World!\nHello World!");
}
// Start the test
echo '== Starting test curl_setopt_array($ch, $options); ==' . "\n";
// curl handler
$ch = curl_init();
// options for the curl handler
$options = array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => 1);
ob_start();
// start output buffering
curl_setopt_array($ch, $options);
$returnContent = curl_exec($ch);
示例3: fopen
<?php
include 'server.inc';
$fp = fopen(dirname(__FILE__) . '/bug48203.tmp', 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, $fp);
curl_setopt($ch, CURLOPT_URL, curl_cli_server_start());
fclose($fp);
// <-- premature close of $fp caused a crash!
curl_exec($ch);
curl_close($ch);
echo "Ok\n";
error_reporting(0);
@unlink(dirname(__FILE__) . '/bug48203.tmp');