如何在ob_get_clean作为数组之后处理php var_转储
下面是我的代码如何在ob_get_clean作为数组之后处理php var_转储,php,Php,下面是我的代码 <?php ob_start(); $incoming = var_dump($_REQUEST); $myFile = "testFile.txt"; $incoming = ob_get_content(); $fh = fopen($myFile, 'w'); fwrite($fh, $incoming); fclose($fh); ?> 然而,我想要的只是价值 我尝试将写调用更改为 fwrite($fh, $incoming[0]); 但是,它只会从字符串
<?php
ob_start();
$incoming = var_dump($_REQUEST);
$myFile = "testFile.txt";
$incoming = ob_get_content();
$fh = fopen($myFile, 'w');
fwrite($fh, $incoming);
fclose($fh);
?>
然而,我想要的只是价值
我尝试将写调用更改为
fwrite($fh, $incoming[0]);
但是,它只会从字符串的数组(1)部分向文件写入一个is 将代码更改为:
<?php
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w');
foreach($_REQUEST as $k => $v)
fwrite($fh, $v);
fclose($fh);
?>
虽然这样做有效,但我并不总是知道该项将被称为什么“钥匙”会在我不知情的情况下改变
<?php
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w');
foreach($_REQUEST as $k => $v)
fwrite($fh, $v);
fclose($fh);
?>