如何防止PHP中的echo,并得到它是什么
How to prevent echo in PHP and get what it is inside?
参考这篇文章如何防止echo-in-php和catch- it-is-inside我试图从下面提到的php文件中获得输出值,但我仍然可以看到这些值在我的php页面的输出中打印出来。任何其他的建议,也欢迎得到输出内容从我的php文件到字符串不得到它的回声。谢谢!
<?php include('Crypto.php')?>
<?php
$workingKey='XXXX'; //Working Key should be provided here.
$encResponse=$_POST["encResp"]; //This is the response sent by the Server
$rcvdString=decrypt($encResponse,$workingKey); //Crypto Decryption used as per the specified working key.
$order_status="";
$order_id=0;
$decryptValues=explode('&', $rcvdString);
$dataSize=sizeof($decryptValues);
echo "<center>";
for($i = 0; $i < $dataSize; $i++)
{
$information=explode('=',$decryptValues[$i]);
if($i==0) $order_id = $information[1];
if($i==1) $tracking_id = $information[1];
if($i==3) $order_status = $information[1];
}
ob_start();
echo $order_id."_";
$out1 = ob_get_contents();
echo $tracking_id."_";
$out2 = ob_get_contents();
echo $order_status;
$out3 = ob_get_contents();
ob_end_clean();
var_dump($out3);
?>
获取HTML格式回显值的JAVASCRIPT代码
class MyJavaScriptInterface
{
@JavascriptInterface
@SuppressWarnings("unused")
public void processHTML(final String html)
{
String order_page = ""+Html.fromHtml(html);//process php output to html
String CCAvenueOrder_id = order_page.split("''_")[0];
String CCAvenueTacking_id=order_page.split("''_")[1];
String CCAvenueOrderStatus=order_page.split("''_")[2];
// process the html as needed by the app
String status = null;
if(html.indexOf("Failure")!=-1){
status = "Transaction Declined!";
}else if(html.indexOf("Success")!=-1){
status = "Transaction Successful!";
}else if(html.indexOf("Aborted")!=-1){
status = " Transaction Cancelled!";
}else{
status = "Status Not Known!";
}
//Toast.makeText(getApplicationContext(), status, Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getApplicationContext(),StatusActivity.class);
startActivity(intent);
}
}
就像在你的问题的注释中一样,你可以将输入存储在一个变量中。输出缓冲区的使用是不必要的,至少在您的示例中不是这样。
<?php
$workingKey='XXXX'; //Working Key should be provided here.
$encResponse=$_POST["encResp"]; //This is the response sent by the Server
$rcvdString=decrypt($encResponse,$workingKey); //Crypto Decryption used as per the specified working key.
$order_status="";
$order_id=0;
$decryptValues=explode('&', $rcvdString);
$dataSize=sizeof($decryptValues);
$output = "<center>";
for ($i = 0; $i < $dataSize; $i++) {
$information=explode('=',$decryptValues[$i]);
if($i==0) $order_id = $information[1];
if($i==1) $tracking_id = $information[1];
if($i==3) $order_status = $information[1];
}
$output .= $order_id."_";
$output .= $tracking_id."_";
$output .= $order_status;
echo $output; // response for ajax request as simple string
?>
如果您不这样做,请告诉我们回显的内容。
检查正在运行的代码内部发生了什么,最好的方法是使用调试器,例如xdebug。了解如何安装它并与您选择的IDE一起使用,然后放置断点并使用监视来窥视变量内部。下面是如何在PhpStorm中做到这一点。
如果您不能安装调试器,或者您绝对需要持久化这些值,请学习日志的概念。有一个PHP-FIG日志记录标准(PSR-3)和至少一个实现它的工具-例如,独白。
相关文章:
- 使用Angular存储用户以前是否选中过复选框,然后再调用它的最佳方式是什么
- 什么是淘汰赛中的根管理员.js以及它指向什么
- 在 http 请求中添加事件侦听器 ( request.on ) 是什么意思?而笏就是它的用途
- _.indexOf() 'item !== item' - 它的目的是什么
- jQuery"return{foo:bar,foo2:bar2}"-它是什么
- 这个cookie是什么(_op_aixPageId)我在很多网站上都看到它
- JavaScript Harmony-它是什么
- Reflect.js,它是什么
- 如何匹配其他一切,但不管它是什么's与regex匹配
- 专注于第一个表单元素,无论它是什么.j查询对话框
- 是否有可用于<对象>的Javascript“Evoke”函数 - 如果有,它是什么
- 它是什么类型的Javascript模式
- sequelize client.uuid,它是什么,它有什么效果
- window.location.hash-它是什么,以及它的用例
- Websocket客户端(浏览器)接收到一个零长度的消息-它是什么?
- 它是什么(function($) {})();的意思
- 它是什么<<我的意思是在Javascript中
- 如果我们只知道一个元素的ID,如何检查它是什么?
- 如何防止PHP中的echo,并得到它是什么
- 如何在JavaScript中查看对象以了解它是什么