dosf40815 2018-08-10 06:53 采纳率: 100%
浏览 28

无法检索$ _POST ['files'']的整数值

PHP script portion : (getting "files = 4" from cpp file):

$downloaded_files = $_POST['files'];
echo($downloaded_files);
$start = $downloaded_files+2;  

The problem is echo($downloaded_files) is working and shows value as "4" in cpp file but $start is always 2.

How do I use value of $_POST['files'] in my program.

  • 写回答

2条回答 默认 最新

  • douan5151 2018-08-10 07:26
    关注

    I'll explain a couple of differences between echo, var_dump and array's.

    Example echo's

    $test = 'Hello, I am a test';
    $second_test = 'Hi! I am a second test';
    
    echo $test; // displays: Hello, I am a test
    echo $second_test; // displays: Hi! I am a second test
    
    echo $test . ' --- ' . $second_test; // displays: Hello, I am a test --- Hi! I am a second test
    

    Echo's are being used to display a single item.

    Documentation:

    http://php.net/manual/en/function.echo.php


    Examples var_dump's and array's
    $test        = 'Hello, I am a string';
    $second_test = [
        'one'   => 'Wassup', // outcome: Wassup
        'two'   => $test, // outcome: Hello, I am a string
        'three' => (1 + 2) // outcome: 3
    ];
    $third_test  = [
        $fourth_test = [
            'sup' => $second_test['two'], // outcome: Hello I am a string
        ],
    ];
    echo '<pre>';
    var_dump($test);
    echo '</pre>';
    //displays:
    //string(20) "Hello, I am a string"
    
    echo '<pre>';
    var_dump($second_test);
    echo '</pre>';
    // displays:
    //array(3) {
    //  ["one"]=>
    //  string(6) "Wassup"
    //  ["two"]=>
    //  string(20) "Hello, I am a string"
    //  ["three"]=>
    //  int(3)
    //}
    
    echo '<pre>';
    var_dump($third_test);
    echo '</pre>';
    // displays:
    //array(1) {
    //  [0]=>
    //  array(1) {
    //      ["sup"]=>
    //    string(20) "Hello, I am a string"
    //  }
    //}
    

    Documentation:

    http://php.net/manual/en/function.var-dump.php

    So related to what you need

    Please use this code to see what the outcome is:

    echo '<pre>';
    var_dump($_POST['files']);
    echo '</pre>';
    

    If the outcome is an array, you can look at the second example on how to display the results.

    I hope this will give you an idea on how to handle your $_POST['files'].

    I will update my answer meanwhile.

    Edit #1:

    $downloaded_files = $_POST['files'];
    echo($downloaded_files);
    $start = $downloaded_files+2;  
    

    Change it to: (note: there are a couple of other ways to get the same result. But I would like to see what happens).

    $downloaded_files = $_POST['files'];
    $start            = ($downloaded_files + 2);
    

    You could also do a var_dump($_POST), to see how many and which items are inside $_POST.

    Edit #2: Please use the following code:

    echo '<pre>';
    var_dump($_POST);
    echo '</pre>';
    

    I need to know what is inside your $_POST.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题