官术网_书友最值得收藏!

  • concrete5 Cookbook
  • David Strack
  • 145字
  • 2021-08-13 16:15:54

Create a custom debugging function

To aid in the dumping of variables, we can create a simple debugging function that will wrap our output in <pre> tags and automatically exit for us.

Place the following code at the top of /config/site_post.php (create the file if it does not exist):

function my_debug($var) {
  echo '<pre>';
  print_r($var);
  echo '</pre>';
  exit;
}
Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Now, when we wish to inspect the contents of a variable or other object, we can simply call my_debug($variable), and get a nicely formatted, easy to read response.

Of course, you are more than welcome to use your own techniques for debugging variables.

主站蜘蛛池模板: 英山县| 阳谷县| 自贡市| 城口县| 治多县| 宜宾县| 丁青县| 峨边| 金门县| 南开区| 田林县| 乌鲁木齐县| 留坝县| 隆德县| 丰宁| 综艺| 扎鲁特旗| 清徐县| 太仓市| 云南省| 青浦区| 雅安市| 大关县| 叙永县| 沂源县| 安达市| 二连浩特市| 盐山县| 黄龙县| 平阴县| 岳池县| 铅山县| 深州市| 景泰县| 海阳市| 漾濞| 鸡西市| 于田县| 哈尔滨市| 黔西县| 柳河县|