Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- curl_setopt_array() function - tests setting multiple cURL options with curl_seto..

Decoded Output download

--TEST--
curl_setopt_array() function - tests setting multiple cURL options with curl_setopt_array()
--CREDITS--
Mattijs Hoitink [email protected]
#Testfest Utrecht 2009
--EXTENSIONS--
curl
--FILE--
<?php
/*
 * 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.inc?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!
Hello World!");
}

// Start the test
echo '== Starting test curl_setopt_array($ch, $options); ==' . "
";

// 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);
curl_close($ch);

var_dump($returnContent);
isset($tempname) and is_file($tempname) and @unlink($tempname);

?>
--EXPECT--
== Starting test curl_setopt_array($ch, $options); ==
string(25) "Hello World!
Hello World!"

Did this file decode correctly?

Original Code

--TEST--
curl_setopt_array() function - tests setting multiple cURL options with curl_setopt_array()
--CREDITS--
Mattijs Hoitink [email protected]
#Testfest Utrecht 2009
--EXTENSIONS--
curl
--FILE--
<?php
/*
 * 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.inc?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);
curl_close($ch);

var_dump($returnContent);
isset($tempname) and is_file($tempname) and @unlink($tempname);

?>
--EXPECT--
== Starting test curl_setopt_array($ch, $options); ==
string(25) "Hello World!
Hello World!"

Function Calls

None

Variables

None

Stats

MD5 4e896c666ada93eb3bc6f9c97744075c
Eval Count 0
Decode Time 82 ms