当前位置:网站首页>VaR in PHP_ export、print_ r、var_ Differences in dump debugging
VaR in PHP_ export、print_ r、var_ Differences in dump debugging
2022-06-24 12:17:00 【PHP Development Engineer 】
1、output basic type
Code
$n = "test";
var_export($n);
print_r($n);
var_dump($n);
echo '-----------------' . '<br/><br/>';
file_put_contents("index.log", var_export($n, true) . PHP_EOL, FILE_APPEND);
file_put_contents("index.log", print_r($n, true) . PHP_EOL, FILE_APPEND);
file_put_contents("index.log", var_dump($n) . PHP_EOL, FILE_APPEND);result
(1) front end :
'test' test /Users/xjnotxj/Program/PhpstormProject/colin/index.php:9:string 'test' (length=4) ----------------- /Users/xjnotxj/Program/PhpstormProject/colin/index.php:15:string 'test' (length=4)
(2)index.log:
'test' test
2、output array
Code
$arr = array(
"a" => 1,
"b" => "222",
"c" => 3,
);
var_export($arr);
print_r($arr);
var_dump($arr);
echo '-----------------' . '<br/><br/>';
file_put_contents("index.log", var_export($arr, true) . PHP_EOL, FILE_APPEND);
file_put_contents("index.log", print_r($arr, true) . PHP_EOL, FILE_APPEND);
file_put_contents("index.log", var_dump($arr) . PHP_EOL, FILE_APPEND);result
(1) front end :
array ( 'a' => 1, 'b' => '222', 'c' => 3, ) Array ( [a] => 1 [b] => 222 [c] => 3 ) /Users/xjnotxj/Program/PhpstormProject/colin/index.php:13: array (size=3) 'a' => int 1 'b' => string '222' (length=3) 'c' => int 3 ----------------- /Users/xjnotxj/Program/PhpstormProject/colin/index.php:19: array (size=3) 'a' => int 1 'b' => string '222' (length=3) 'c' => int 3
(2)index.log:
array ( 'a' => 1, 'b' => '222', 'c' => 3, ) Array ( [a] => 1 [b] => 222 [c] => 3 )
3、output object
Code
class foo
{
public $n;
public function do_foo()
{
echo "Doing foo." . $this->n;
}
}
$object = new foo;
var_export($object);
print_r($object);
var_dump($object);
echo '-----------------' . '<br/><br/>';
file_put_contents("index.log", var_export($object, true) . PHP_EOL, FILE_APPEND);
file_put_contents("index.log", print_r($object, true) . PHP_EOL, FILE_APPEND);
file_put_contents("index.log", var_dump($object) . PHP_EOL, FILE_APPEND);result
(1) front end :
foo::__set_state(array( 'n' => NULL, )) foo Object ( [n] => ) /Users/xjnotxj/Program/PhpstormProject/colin/index.php:19: object(foo)[1] public 'n' => null ----------------- /Users/xjnotxj/Program/PhpstormProject/colin/index.php:25: object(foo)[1] public 'n' => null
(2)index.log:
foo::__set_state(array( 'n' => NULL, )) foo Object ( [n] => )
summary :
1、 Details of output results : var_export ≈ print_r < var_dump
2、 When debugging , call var_export、print_r、var_dump When , no need Add before echo .
3、var_export,print_r Of The second parameter is true Return value .var_dump I won't support it , So use file_put_contents Do not use... When output debugging var_dump.
4、 It is recommended that the debugging of the development environment be used directly var_dump, You can get detailed debugging information and code line number positioning ; Debugging of production environment var_export or print_r, Remember to set the second parameter to true Convert to return output value , Not directly output to the front-end influence line .
summary
The above is a brief introduction PHP in var_export、print_r、var_dump The difference in debugging , I hope that's helpful , If you have any questions, please leave me a message , Xiaobian will reply to you in time . Thank you very much for Open source dominates Support for !
Complete example :http://github.crmeb.net/u/defu
come from “ Open source world ” , link :https://ym.baisou.ltd/post/676.html, If you want to reprint , Please indicate the source , Otherwise, the legal liability will be investigated .
边栏推荐
- PF_ Ring ZC | high speed traffic processing dpdk alternative
- Programmers spend most of their time not writing code, but...
- How stupid of me to hire a bunch of programmers who can only "Google"!
- Insurance app aging service evaluation analysis 2022 issue 06
- Why choose b+ tree as storage engine index structure
- 12+!不同癌症中TMB与ICI反应之间的免疫相关因素研究
- 美团基于 Flink 的实时数仓平台建设新进展
- 打新债的条件 开户是安全的吗
- Speculation London gold short-term stable money making skills? Where is it safe to fry London gold?
- 怎样申请打新债 开户是安全的吗
猜你喜欢

Opencv learning notes - regions of interest (ROI) and image blending

《梦华录》要大结局了,看超前点映不如先来学学它!
![[digital ic/fpga] booth multiplier](/img/42/3da3b1d3cc82cb9c0694241148011b.png)
[digital ic/fpga] booth multiplier

"Meng Hua Lu" is about to have a grand finale. It's better to learn it first than to look ahead!

链接器 --- Linker

Installation and operation of libuv
Deep parsing and implementation of redis pub/sub publish subscribe mode message queue

AXI低功耗接口

软件测试 对前一日函数的基本路径测试

《opencv学习笔记》-- 分离颜色通道、多通道混合
随机推荐
打新债可以申请多少 开户是安全的吗
How stupid of me to hire a bunch of programmers who can only "Google"!
What are the low threshold financial products in 2022? Not much money
I'm in Shenzhen. Where can I open an account? Is it safe to open an account online now?
Jenkins remote publishing products
Is it safe to open an account under the conditions of new bonds
5 points + single gene pan cancer pure Shengxin idea!
Opencv learning notes - loading and saving images
11+! Methylation modification patterns based on m6A regulatory factors in colon cancer are characterized by different tumor microenvironment immune spectra
GLOG从入门到入门
5分+的单基因泛癌纯生信思路!
深度学习~11+高分疾病相关miRNA研究新视角
Embedded must learn! Detailed explanation of hardware resource interface - based on arm am335x development board (Part 2)
怎样申购打新债 开户是安全的吗
Tsingsee green rhino video "cloud side end" +ai intelligent security system is integrated into the mainstream development trend
Tools and methods - use code formatting tools in source insight
Variable parameter template implements max (accepts multiple parameters, two implementation methods)
GLOG from getting started to getting started
C语言循环语句介绍(foe、while、do...while)
How to develop mRNA vaccine? 27+ pancreatic cancer antigen and immune subtype analysis to tell you the answer!