熊猫购彩

<meter id="pgsoe"></meter>

<code id="pgsoe"><u id="pgsoe"></u></code>

<acronym id="pgsoe"><video id="pgsoe"></video></acronym>
    1. <label id="pgsoe"></label>
  • <acronym id="pgsoe"><legend id="pgsoe"><blockquote id="pgsoe"></blockquote></legend></acronym>
      <label id="pgsoe"></label>
    <acronym id="pgsoe"></acronym>
  • <meter id="pgsoe"><u id="pgsoe"><option id="pgsoe"></option></u></meter>
    <output id="pgsoe"></output>
  • <var id="pgsoe"><ol id="pgsoe"></ol></var>
    LaravelConf Taiwan 2020 CFP Started

    Supported Protocols and Wrappers

    PHP comes with many built-in wrappers for various URL-style protocols for use with the filesystem functions such as fopen(), copy(), file_exists() and filesize(). In addition to these wrappers, it is possible to register custom wrappers using the stream_wrapper_register() function.

    Note: The URL syntax used to describe a wrapper only supports the scheme://... syntax. The scheme:/ and scheme: syntaxes are not supported.

    Table of Contents

    add a note add a note

    User Contributed Notes 30 notes

    up
    8
    Anonymous
    2 years ago
    If you want to filter incoming data through php://input use this:

    file_get_contents("php://filter/read=string.strip_tags/resource=php://input");

    I couldn't find any documentation to explain how to do this. All the examples I came across suggested that a full and actual URL had to be used (which didn't work for me).

    This seems to work though.
    up
    13
    sander at medicore dot nl
    12 years ago
    to create a raw tcp listener system i use the following:

    xinetd daemon with config like:
    service test
    {
            disable      = no
            type         = UNLISTED
            socket_type  = stream
            protocol     = tcp
            bind         = 127.0.0.1
            port         = 12345
            wait         = no
            user         = apache
            group        = apache
            instances    = 10
            server       = /usr/local/bin/php
            server_args  = -n [your php file here]
            only_from    = 127.0.0.1 #gotta love the security#
            log_type     = FILE /var/log/phperrors.log
            log_on_success += DURATION
    }

    now use fgets(STDIN) to read the input. Creates connections pretty quick, works like a charm.Writing can be done using the STDOUT, or just echo. Be aware that you're completely bypassing the webserver and thus certain variables will not be available.
    up
    13
    fabacrans__ at __nospamhotmail__ dot __com
    7 years ago
    You can use "php://input" to accept and parse "PUT", "DELETE", etc. requests.

    <?php
    // Example to parse "PUT" requests
    parse_str(file_get_contents('php://input'), $_PUT);

    // The result
    print_r($_PUT);
    ?>

    (very useful for Restful API)
    up
    5
    Hayley Watson
    2 years ago
    Even though their names will be the same, you can have more than one //memory or //temp stream open concurrently; each time you fopen() such a stream, a NEW stream will be opened independently of the others.

    This is hinted at by the fact you don't add any unique identifier to the path when creating such streams, but isn't said explicitly.

    <?php

    $hello
    = fopen('php://memory', 'r+'); // $hello, $php, $world are all different streams.
    $php  = fopen('php://memory', 'r+');
    $world = fopen('php://memory', 'r+'); // They're not the same stream opened three times.

    fputs($hello, "Hello ");
    fputs($php, "PHP ");
    rewind($php);
    fputs($world, "World!");
    rewind($hello);
    rewind($world);

    echo
    '[', stream_get_contents($hello), '][', stream_get_contents($php), '][', stream_get_contents($world), ']';
    // If they were the same stream the output would be "[World!][World!][World!]".
    ?>
    up
    6
    heitorsiller at uol dot com dot br
    13 years ago
    For reading a XML stream, this will work just fine:
    <?php

    $arq
    = file_get_contents('php://input');

    ?>

    Then you can parse the XML like this:

    <?php

    $xml
    = xml_parser_create();

    xml_parse_into_struct($xml, $arq, $vs);

    xml_parser_free($xml);

    $data = "";

    foreach(
    $vs as $v){

            if(
    $v['level'] == 3 && $v['type'] == 'complete')
                   
    $data .= "\n".$v['tag']." -> ".$v['value'];
    }

    echo
    $data;

    ?>

    PS.: This is particularly useful for receiving mobile originated (MO) SMS messages from cellular phone companies.
    up
    4
    ben dot johansen at gmail dot com
    13 years ago
    Example of how to use the php://input to get raw post data

    //read the raw data in
    $roughHTTPPOST = file_get_contents("php://input");
    //parse it into vars
    parse_str($roughHTTPPOST);

    if you do readfile("php://input") you will get the length of the post data
    up
    4
    ben dot johansen at gmail dot com
    13 years ago
    In trying to do AJAX with PHP and Javascript, I came upon an issue where the POST argument from the following javascript could not be read in via PHP 5 using the $_REQUEST or $_POST. I finally figured out how to read in the raw data using the php://input directive.
       
    Javascript code:
    =============
          //create request instance     
          xhttp = new XMLHttpRequest();
          // set the event handler
          xhttp.onreadystatechange = serviceReturn;
          // prep the call, http method=POST, true=asynchronous call
          var Args = 'number='+NbrValue;
          xhttp.open("POST", "http://<?php echo $_SERVER['SERVER_NAME'] ?>/webservices/ws_service.php", true);
          // send the call with args
          xhttp.send(Args);

    PHP Code:
        //read the raw data in
        $roughHTTPPOST = file_get_contents("php://input");
        //parse it into vars
        parse_str($roughHTTPPOST);
    up
    3
    aidan at php dot net
    16 years ago
    The contants:

    * STDIN
    * STDOUT
    * STDERR

    Were introduced in PHP 4.3.0 and are synomous with the fopen('php://stdx') result resource.
    up
    3
    Justin Megawarne
    7 years ago
    If my understanding of the implementing code is correct, every time you open a php://memory stream, you get new storage allocated. That is to say, php://memory isn't a shared bank of memory.
    up
    4
    sam at bigwig dot net
    16 years ago
    [ Editor's Note: There is a way to know.  All response headers (from both the final responding server and intermediate redirecters) can be found in $http_response_header or stream_get_meta_data() as described above. ]

    If you open an HTTP url and the server issues a Location style redirect, the redirected contents will be read but you can't find out that this has happened.

    So if you then parse the returned html and try and rationalise relative URLs you could get it wrong.
    up
    3
    php at rapsys dot eu
    7 years ago
    Here is a snippet to read compressed raw post data without enabling global variables.

    I needed it to read xml posted data submitted by ocs agent. The data was sent as Content-Type: application/x-compressed (zlib compressed data).

    It seems related to an old bug which still seems broken :
    https://bugs.php.net/bug.php?id=49411

    The important part is the default window set to 15 instead of -15.

    Code snippet
    <?php
    $data
    = '';
    $fh = fopen('php://input', 'rb');
    stream_filter_append($fh, 'zlib.inflate', STREAM_FILTER_READ, array('window'=>15));
    while(!
    feof($fh)) {
       
    $data .= fread($fh, 8192);
    }
    ?>
    up
    3
    jerry at gii dot co dot jp
    12 years ago
    Not only are STDIN, STDOUT, and STDERR only allowed for CLI programs, but they are not allowed for programs that are read from STDIN. That can confuse you if you try to type in a simple test program.
    up
    3
    aaron dot mason+php at thats-too-much dot info
    7 years ago
    Be aware of code injection, folks - like anything else you take from the user, SANITISE IT FIRST.  This cannot be stressed enough - if I had a dollar for each time I saw code where form input was taken and directly used (by myself as well, I've been stupid too) I'd probably own PHP.  While using data from a form in a URL wrapper is asking for trouble, you can greatly minimise the trouble by making sure your inputs are sane and not likely to provide an opening for the LulzSec of the world to cause havoc.
    up
    2
    ohcc at 163 dot com
    4 years ago
    <?php
       
    //enable $HTTP_RAW_POST_DATA when necessary
       
    ini_set('always_populate_raw_post_data',-1);
       
    $HTTP_RAW_POST_DATA = file_get_contents('php://input');
        echo
    $HTTP_RAW_POST_DATA;
    ?>
    up
    4
    gjaman at gmail dot com
    12 years ago
    You can decompress (gzip) a input stream by combining wrappers:

    eg:  $x = file_get_contents("compress.zlib://php://input");

    I used this method to decompress a gzip stream that was pushed to my webserver
    up
    2
    Anonymous
    4 years ago
    Note that STDIN and similar are defined only in CLI
    up
    2
    sebastian dot krebs at kingcrunch dot de
    9 years ago
    The stream php://temp/maxmemory:$limit stores the data in memory unless the limit is reached. Then it will write the whole content the a temporary file and frees the memory. I didnt found a way to get at least some of the data back to memory.
    up
    2
    oliver at codeinline dot com
    6 years ago
    A useful way to handle large file uploads is to do something like:

    copy(("php://input"),$tmpfile);

    as this avoids using lots of memory just to buffer the file content.

    The correct mime type for this should be "application/octet-stream" however if you set this or any other recognised mime type other than "multipart/form-data" on your POST then $HTTP_RAW_POST_DATA is populated and the memory is consumed anyway.

    Setting the mime type to "multipart/form-data" raises “PHP Warning:  Missing boundary in multipart/form-data POST data in Unknown on line 0” however it seems to work without a problem.
    up
    2
    lupti at yahoo dot com
    16 years ago
    I find using file_get_contents with php://input is very handy and efficient. Here is the code:

    $request = "";
    $request = file_get_contents("php://input");

    I don't need to declare the URL filr string as "r". It automatically handles open the file with read.

    I can then use this $request string to your XMLparser as data.
    up
    2
    nyvsld at gmail dot com
    14 years ago
    php://stdin supports fseek() and fstat() function call,
    while php://input doesn't.
    up
    1
    vibhavsinha91 at gmail dot com
    5 years ago
    While writing to error stream, error_log() function comes as a shorthand to writing to php://stderr . This function also allows writing to web server log when running through a web server such as apache.
    up
    1
    Anonymous
    8 years ago
    For php://filter the /resource=foo part must come last. And foo needs no escaping at all.
    php://filter/resource=foo/read=somefilter would try to open a file 'foo/read=somefilter' while php://filter/read=somefilter/resource=foo will open file 'foo' with the somefilter filter applied.
    up
    1
    ben dot johansen at gmail dot com
    13 years ago
    followup:

    I found that if I added this line to the AJAX call, the values would show up in the $_POST

    xhttp.setRequestHeader('Content-Type',
    'application/x-www-form-urlencoded');
    up
    1
    chris at free-source dot com
    15 years ago
    If you're looking for a unix based smb wrapper there isn't one built in,  but I've had luck with http://www.zevils.com/cgi-bin/viewcvs.cgi/libsmbclient-php/ (tarball link at the end).
    up
    0
    leonid at shagabutdinov dot com
    8 years ago
    For https for windows enable this extension:

    extension=php_openssl.dll
    up
    0
    nargy at yahoo dot com
    15 years ago
    When opening php://output in append mode you get an error, the way to do it:
    $fp=fopen("php://output","w");
    fwrite($fp,"Hello, world !<BR>\n");
    fclose($fp);
    up
    -3
    dave at 4mation dot com dot au
    6 years ago
    The use of php://temp/maxmemory as a stream counts towards the memory usage of the script; you are not specifying a new memory pool by using this type of stream.
    As noted in the documentation however, this stream type will start to write to a file after the specified maxmemory limit is exceeded. This file buffer is NOT observed by the memory limit.
    This is handy if you want your script to have a reasonably small memory limit (eg 32MB) but but still be able to handle a huge amount of data in a stream (eg 256MB)

    The only works if you use stream functions like fputs(); if you use $buffer .= 'string'; or $buffer = $buffer . 'string'; you're calling your stream data back into PHP and this will hit the limiter.

    As a practical example:

    <?php
    // 0.5MB memory limit
    ini_set('memory_limit', '0.5M');
    // 2MB stream limit
    $buffer = fopen('php://temp/maxmemory:1048576', 'r+');
    $x = 0;
    // Attempt to write 1MB to the stream
    while ($x < 1*1024*1024) {
       
    fputs($buffer, 'a');
       
    $x++;
    }
    echo
    "This will never be displayed";
    ?>

    However, change fopen to use php://temp/maxmemory:1 (one byte, rather than one megabyte) and it will begin writing to the unlimited file stream immediately, avoiding memory limit errors.
    up
    -3
    Anonymous
    7 years ago
    In PHP 5.4+ you can read multipart data via php://input if you set enable_post_data_reading to Off.

    Of course if you set it to off, the $_POST and $_FILES superglobals won't be populated at all. It's entirely up to you to parse the data now.
    up
    -2
    Anonymous
    2 years ago
    Be forewarned:

    the file:// protocol used in file_get_contents is used as the default for "any unrecognized protocol." Thus:

    aldfjadlfadfladfl://whatever

    will deliver the same as

    file://whatever
    up
    -6
    nguyenanthuan at gmail dot com
    5 years ago
    Each stream pointer to php://memory and php://temp has its own memory allocation, so you can open many stream pointers to store your separated values.

    <?php
    $fp
    = fopen("php://temp", "r+");
    $fp2 = fopen("php://temp", "r+");

    fwrite($fp, "line1\n");
    fwrite($fp2, "line4\n");
    fwrite($fp, "line2\n");
    fwrite($fp2, "line5\n");
    fwrite($fp, "line3\n");
    fwrite($fp2, "line6\n");

    var_dump(memory_get_usage());

    rewind($fp);
    while(!
    feof($fp)) {
       
    var_dump(fread($fp, 1024));
    }
    fclose($fp);
    var_dump(memory_get_usage());

    rewind($fp2);
    while(!
    feof($fp2)) {
       
    var_dump(fread($fp2, 1024));
    }
    fclose($fp2);
    var_dump(memory_get_usage());
    ?>

    Closing their stream handles will also free the allocated memory.

    php://memory stream type is MEMORY, while php://temp stream type is STDIO FILE*.
    To Top
    济宁| 通化| 博湖| 北戴河| 乌拉特前旗| 永吉| 楚雄| 留坝| 肥东| 江口| 海安| 廉江| 滦南| 康保| 淖毛湖| 卓资| 通辽钱家店| 嵊山| 威海| 彰武| 临湘| 平邑| 德格| 类乌齐| 东阳| 昌邑| 奉化| 大理| 横山| 临湘| 饶平| 加格达奇| 木垒| 新乡| 平和| 武威| 阳信| 肃宁| 剑阁| 林芝| 太原北郊| 宜川| 澄海| 伊宁县| 绍兴| 景德镇| 斋堂| 太原| 丹东| 镇赉| 通江| 崇义| 张家港| 清涧| 金川| 霍州| 沾益| 嘉兴| 应县| 石门| 隰县| 乌当| 右玉| 洪洞| 巴盟农试站| 灵宝| 平坝| 思南| 贞丰| 三门| 金坛| 东海| 密云| 东山| 满洲里| 利川| 玛多| 尤溪| 赤峰郊区站| 广水| 东川| 岐山| 周村| 邓州| 临澧| 贵港| 富川| 上川岛| 通山| 东营| 茂县| 泾阳| 临高| 罗子沟| 炮台| 万源| 牟平| 恩施| 天池| 陈家镇| 阿巴嘎旗| 杂多| 泉州| 马山| 江城| 独山| 遂平| 民和| 昭苏| 理县| 高淳| 康保| 宁陵| 长寿| 冷湖| 平坝| 新兴| 兴和| 鸡公山| 甘德| 炮台| 唐山| 马山| 枝江| 武山| 呼兰| 盐亭| 淇县| 那坡| 阿瓦提| 钟祥| 南澳| 郑州农试站| 古田| 虎林| 土默特左旗| 临河| 冀州| 四子王旗| 绥滨| 敖汉旗| 长葛| 宜城| 察哈尔右翼中旗| 天等| 合作| 永德| 马鞍山| 襄阳| 任县| 德昌| 城固| 定边| 正宁| 天峻| 崆峒| 海西| 岳普湖| 廉江| 永丰| 六枝| 错那| 阿鲁科尔沁旗| 华阴| 夹江| 靖边| 柘荣| 吐尔尕特| 巴盟农试站| 铁卜加寺| 岑溪| 岫岩| 孟州| 明水| 韩城| 迁西| 密云| 永兴| 青阳| 澄迈| 沅江| 阳谷| 屯昌| 开江| 福海| 宜宾县| 海渊| 长阳| 佛山| 海伦| 邢台| 邹平| 芒康| 加查| 漯河| 信阳| 小灶火| 和平| 马坡岭| 临夏| 长治| 永清| 牟定| 海林| 祁门| 鸡西| 成山头| 乌海| 海晏| 夷陵| 宝兴| 太原古交区| 泊头| 阿图什| 马尔康| 鄂尔多斯| 翁牛特旗| 石拐| 莱州| 台中| 曲江| 崇阳| 户县| 朱日和| 海淀| 南召| 峨山| 内邱| 镇江| 九华山| 崂山| 宜兴| 利川| 邵武| 东吉屿| 阿合奇| 永定| 东乡| 集宁| 上林| 吴忠| 铁干里克| 吐鲁番| 德清| 横山| 安远| 石拐| 库尔勒| 石拐| 郯城| 睢宁| 尤溪| 乐安| 方正| 永胜| 云县| 湖口| 两当| 富县| 忻城| 长丰| 乡宁| 阆中| 文成| 屏边| 长治| 漳平| 腾冲| 林甸| 天镇| 大通| 施秉| 城步| 绩溪| 安仁| 宝应| 昌邑| 元氏| 辽源| 大石桥| 孝义| 眉山| 宕昌| 临高| 石楼| 东至| 凌云| 德化| 察哈尔右翼中旗| 延吉| 长治| 景县| 沁水| 河曲| 乌恰| 太原南郊| 乌鲁木齐| 黄南| 朱日和| 夏县| 大港| 郏县| 靖西| 秭归| 全州| 温宿| 理县| 安图| 和顺| 苍南| 鹤城区| 旬阳| 昌乐| 定州| 公安| 滑县| 商洛| 兴和| 东兴| 安义| 额敏| 石林| 海晏| 陆川| 西宁| 渠县| 平陆| 鄢陵| 宜宾县| 勉县| 资兴| 玉溪| 丰都| 藤县| 蕉岭| 贵溪| 平坝| 宜宾县| 长寿| 松桃| 临清| 涞源| 蕲春| 北辰| 嘉鱼| 南涧| 吴江| 通什| 扎赉特旗| 永城| 赣州| 独山| 平塘| 陆丰| 丹棱| 红河| 安福| 五道梁| 常州| 安定| 玉山| 柘荣| 蒲县| 汉沽| 改则| 水城| 怀来| 舟曲| 铅山| 璧山| 屯留| 石嘴山| 纳雍| 康定| 佛山| 瑞金| 青铜峡| 郧县| 丁青| 克拉玛依| 成安| 韶关| 彭阳| 镇源| 荣成| 罗平| 淄川| 遵义县| 狮泉河| 夹江| 扎鲁特旗| 杂多| 启东| 华安| 茶陵| 盐源| 宁冈| 轮台| 阿拉善左旗| 高阳