


This article mainly introduces the differences between var_export, print_r, and var_dump debugging in PHP. It is very good and has certain reference value. Friends in need can refer to it
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. Detailed output results: var_export ≈ print_r 2. When debugging, when calling var_export, print_r, var_dump, there is no need to add echo in front. 3. If the second parameter of var_export and print_r is true, the value will be returned. var_dump does not support , so do not use var_dump when using file_put_contents to output debugging. 4. It is recommended to use var_dump directly for debugging in the development environment to obtain detailed debugging information and code line positioning; to use var_export or print_r for debugging in the production environment. Remember to set the second parameter to true to return output. value instead of outputting it directly to the front-end influence line. The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website! Related recommendations:Use PHP to implement Chinese pinyin conversion and Gregorian and lunar calendar conversion
About PHP’s move_uploaded_file() function Analysis
The above is the detailed content of About the difference between var_export, print_r and var_dump in debugging in PHP. For more information, please follow other related articles on the PHP Chinese website!

dump文件通常是指一种二进制文件,也被称为转储文件或核心转储文件。这种文件是计算机系统在遇到严重错误或异常情况时生成的,用于存储系统或应用程序的状态、堆栈、寄存器、内存映像、日志等信息。

VueCli中出现'Therequestedmoduledoesnotprovideanexportnamed'Error–怎么解决?在Vue项目的开发过程中,我们可能会遇到'Therequestedmoduledoesnotprovideanexportnamed'的错误提示。这个错误提示一般会出现在引入第三方组件时

关于 R 的一点背景R 是一种编程语言和分析工具,由 Ross Ihaka 和 Robert Gentleman 开发,并于 1993 年首次推出。同时,它也是免费的开源软件,拥有丰富的 统计和图形化技术库。R 是 分析师、统计学家 和 研究人员 用得最多的工具之一,用于 检索、清理、分析、可视化 和 呈现数据,很多行业如 IT、银行、医疗、金融都使用 R。用途 数据科学家可以使用 R 编程语言来收集数据,进行统计分析,并产生可视化结果。 它可以用于图形化表示。 R 既可用于机器学习,也可用于深

音频输出和输入需要特定的驱动程序和服务才能在Windows11上按预期工作。这些有时最终会在后台遇到错误,从而导致音频问题,如无音频输出、缺少音频设备、音频失真等。如何修复在Windows11上没有响应的音频服务我们建议您从下面提到的修复开始,并逐步完成列表,直到您设法解决您的问题。由于Windows11上的多种原因,音频服务可能无法响应。此列表将帮助您验证和修复阻止音频服务在Windows11上响应的大多数问题。请按照以下相关部分帮助您完成该过程。方法一:重启音频服务您可能会遇

PHP中var关键字的作用和示例在PHP中,var关键字用于声明一个变量。以前的PHP版本中,使用var关键字是声明成员变量的惯用方式,现在已经不再推荐使用。然而,在某些情况下,var关键字依然会被使用。var关键字主要用于声明一个局部变量,并且会自动将该变量标记为局部作用域。这意味着该变量仅在当前的代码块中可见,并且不能在其他函数或代码块中访问。使用var

本篇文章给大家带来了关于JavaScript的相关知识,其中主要给大家介绍了var、let以及const的区别有哪些,还有ECMAScript 和 JavaScript的关系介绍,感兴趣的朋友一起来看一下吧,希望对大家有帮助。

Redstone (RED)空投活动为BNB持有者带来丰厚收益!Redstone,一个支持70多个区块链、覆盖1250多个资产的创新型多链预言机项目,其代币RED通过币安Launchpool进行空投。参与活动,BNB持有者可将闲置资产投入RED奖励池进行挖矿,获得RED代币,实现资产增值,提高资产利用效率,并丰富投资组合,降低风险。 但需注意加密货币市场波动性,理性投资,谨慎评估风险。 立即参与Redstone (RED)空投,抓住财富机遇!

export和export default的区别是export关键字用于导出一个或多个变量、函数或类,而export default关键字用于导出一个默认的变量、函数或类。在其他模块中,可以使用import关键字来导入这些导出的变量、函数或类。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
