当前位置: 首页>>代码示例>>PHP>>正文


PHP php_cli_server_start函数代码示例

本文整理汇总了PHP中php_cli_server_start函数的典型用法代码示例。如果您正苦于以下问题:PHP php_cli_server_start函数的具体用法?PHP php_cli_server_start怎么用?PHP php_cli_server_start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了php_cli_server_start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start('chdir(__DIR__); echo "okey";');
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS));
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS));
开发者ID:gleamingthecube,项目名称:php,代码行数:6,代码来源:sapi_cli_tests_php_cli_server_003.php

示例2: exit

<?php

require __DIR__ . "/../../sapi/cli/tests/php_cli_server.inc";
$code = <<<'FL'
 if(!ini_get('enable_post_data_reading')){
  if($_SERVER['REQUEST_METHOD']=='POST'){
   exit(file_get_contents('php://input'));
  }
 }else{
  exit('Please SET php.ini: enable_post_data_reading = Off');
 }
FL;
$postdata = "PASS";
$opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context = stream_context_create($opts);
php_cli_server_start("exit(file_get_contents('php://input'));", false, "-d enable_post_data_reading=Off");
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context));
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS, false, $context));
开发者ID:gleamingthecube,项目名称:php,代码行数:18,代码来源:tests_basic_bug67198.php

示例3: header

<?php

$stub = "<?php header('Content-Type: text/plain;');\nPhar::mount('this.file', '" . __FILE__ . "');\necho 'OK\n';\n__HALT_COMPILER(); ?>";
$p = new Phar(__DIR__ . '/issue0149.phar.php', 0, 'this');
$p['index.php'] = "";
# A Phar must have at least one file, hence this dummy
$p->setStub($stub);
unset($p);
include "php_cli_server.inc";
php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1');
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php');
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php');
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/issue0149.phar.php');
@unlink(__DIR__ . '/issue0149.phar.php');
开发者ID:badlamer,项目名称:hhvm,代码行数:14,代码来源:issue0149.php

示例4: include

$file2 = "{$dir2}/index.php";
$main = "{$dir}/main.php";
@mkdir($dir1);
@mkdir($dir2);
@file_put_contents($main, '<?php include(\'' . $link . '/index.php\');');
@file_put_contents($file1, "TEST 1\n");
@file_put_contents($file2, "TEST 2\n");
while (filemtime($file1) != filemtime($file2)) {
    touch($file1);
    touch($file2);
}
@unlink($link);
@symlink($dir1, $link);
include "php_cli_server.inc";
//php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.revalidate_path=1');
php_cli_server_start('-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.revalidate_path=1 -d opcache.file_update_protection=0 -d realpath_cache_size=0');
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
@unlink($link);
@symlink($dir2, $link);
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
echo file_get_contents('http://' . PHP_CLI_SERVER_ADDRESS . '/main.php');
$dir = dirname(__FILE__);
$dir1 = "{$dir}/test1";
$dir2 = "{$dir}/test2";
$link = "{$dir}/test";
$file1 = "{$dir1}/index.php";
$file2 = "{$dir2}/index.php";
$main = "{$dir}/main.php";
@unlink($main);
@unlink($link);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:revalidate_path_01.php

示例5: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start('var_dump($_SERVER["PHP_SELF"], $_SERVER["SCRIPT_NAME"], $_SERVER["PATH_INFO"], $_SERVER["QUERY_STRING"]);', null);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
GET /foo/bar?foo=bar HTTP/1.1
Host: {$host}


HEADER
)) {
    while (!feof($fp)) {
        echo fgets($fp);
    }
}
fclose($fp);
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
GET /index.php/foo/bar/?foo=bar HTTP/1.0
Host: {$host}

开发者ID:gleamingthecube,项目名称:php,代码行数:29,代码来源:sapi_cli_tests_php_cli_server_010.php

示例6: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start(<<<'PHP'
var_dump($_SERVER['SCRIPT_FILENAME']);
PHP
);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
POST / HTTP/1.1
Host: {$host}


HEADER
)) {
    while (!feof($fp)) {
        echo fgets($fp);
    }
}
fclose($fp);
开发者ID:gleamingthecube,项目名称:php,代码行数:25,代码来源:sapi_cli_tests_php_cli_server_017.php

示例7: dirname

<?php

include dirname(__FILE__) . "/../../../../sapi/cli/tests/php_cli_server.inc";
php_cli_server_start(file_get_contents(dirname(__FILE__) . '/bug64433_srv.inc'));
echo file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/index.php");
echo "default\n";
$codes = array(200, 201, 204, 301, 302, 303, 304, 305, 307, 404, 500);
foreach ($codes as $code) {
    echo "{$code}: " . file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/index.php?status={$code}&loc=1");
}
echo "follow=0\n";
$arr = array('http' => array('follow_location' => 0));
$context = stream_context_create($arr);
foreach ($codes as $code) {
    echo "{$code}: " . file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/index.php?status={$code}&loc=1", false, $context);
}
echo "follow=1\n";
$arr = array('http' => array('follow_location' => 1));
$context = stream_context_create($arr);
foreach ($codes as $code) {
    echo "{$code}: " . file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS . "/index.php?status={$code}&loc=1", false, $context);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:22,代码来源:bug64433.php

示例8: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start('var_dump($_SERVER["DOCUMENT_ROOT"], $_SERVER["SERVER_SOFTWARE"], $_SERVER["SERVER_NAME"], $_SERVER["SERVER_PORT"]);');
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS));
开发者ID:gleamingthecube,项目名称:php,代码行数:5,代码来源:sapi_cli_tests_php_cli_server_002.php

示例9: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start('var_dump($_SERVER["PATH_INFO"]);', null);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
GET /foo/bar HTTP/1.1
Host: {$host}


HEADER
)) {
    while (!feof($fp)) {
        echo fgets($fp);
    }
}
fclose($fp);
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
GET /foo/bar/ HTTP/1.0
Host: {$host}

开发者ID:gleamingthecube,项目名称:php,代码行数:29,代码来源:sapi_cli_tests_php_cli_server_009.php

示例10: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start(<<<'PHP'
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"]))
        return false; // serve the requested resource as-is.
else {
        echo "here";
}
PHP
);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
POST /no-exists.jpg HTTP/1.1
Host: {$host}


HEADER
)) {
    while (!feof($fp)) {
        echo fgets($fp);
        break;
    }
}
fclose($fp);
开发者ID:zaky-92,项目名称:php-1,代码行数:30,代码来源:sapi_cli_tests_php_cli_server_016.php

示例11: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start();
var_dump(file_get_contents("http://" . PHP_CLI_SERVER_ADDRESS));
开发者ID:gleamingthecube,项目名称:php,代码行数:5,代码来源:sapi_cli_tests_php_cli_server_001.php

示例12: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start(<<<'PHP'
echo "This should never echo";
PHP
);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
// Send a request with a fictitious request method,
// I like smurfs, the smurf everything.
if (fwrite($fp, <<<HEADER
SMURF / HTTP/1.1
Host: {$host}


HEADER
)) {
    while (!feof($fp)) {
        echo fgets($fp);
        // Only echo the first line from the response,
        // the rest is not interesting
        break;
    }
}
fclose($fp);
开发者ID:gleamingthecube,项目名称:php,代码行数:30,代码来源:sapi_cli_tests_bug61679.php

示例13: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start(NULL, NULL);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$output = '';
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
POST / HTTP/1.1
Host: {$host}
Content-Type: application/x-www-form-urlencoded
Content-Length: 3

a=b
HEADER
)) {
    while (!feof($fp)) {
        $output .= fgets($fp);
    }
}
echo preg_replace("/<style>(.*?)<\\/style>/s", "<style>AAA</style>", $output), "\n";
fclose($fp);
$output = '';
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:sapi_cli_tests_php_cli_server_013.php

示例14: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start('print_r($_REQUEST); $_REQUEST["foo"] = "bar"; return FALSE;');
$doc_root = __DIR__;
file_put_contents($doc_root . '/request.php', '<?php print_r($_REQUEST); ?>');
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
POST /request.php HTTP/1.1
Host: {$host}
Content-Type: application/x-www-form-urlencoded
Content-Length: 3

a=b
HEADER
)) {
    while (!feof($fp)) {
        echo fgets($fp);
    }
}
fclose($fp);
@unlink($doc_root . '/request.php');
开发者ID:gleamingthecube,项目名称:php,代码行数:27,代码来源:sapi_cli_tests_php_cli_server_012.php

示例15: php_cli_server_start

<?php

include "php_cli_server.inc";
php_cli_server_start(<<<'PHP'
header('Bar-Foo: Foo');
var_dump(getallheaders());
var_dump(apache_request_headers());
var_dump(apache_response_headers());
PHP
);
list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS);
$port = intval($port) ?: 80;
$fp = fsockopen($host, $port, $errno, $errstr, 0.5);
if (!$fp) {
    die("connect failed");
}
if (fwrite($fp, <<<HEADER
GET / HTTP/1.1
Host: {$host}
Foo-Bar: Bar


HEADER
)) {
    while (!feof($fp)) {
        echo fgets($fp);
    }
}
fclose($fp);
开发者ID:gleamingthecube,项目名称:php,代码行数:29,代码来源:sapi_cli_tests_php_cli_server_019.php


注:本文中的php_cli_server_start函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。