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

  • 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.

主站蜘蛛池模板: 克什克腾旗| 绍兴县| 娄烦县| 安西县| 新建县| 顺平县| 思茅市| 左云县| 卢氏县| 若尔盖县| 岳西县| 资阳市| 集贤县| 庐江县| 新绛县| 青岛市| 开阳县| 利津县| 元氏县| 九龙县| 昂仁县| 吕梁市| 南木林县| 台北县| 潼南县| 枣强县| 揭西县| 安远县| 庆阳市| 临清市| 嘉义市| 翁源县| 西藏| 新民市| 丹东市| 上虞市| 鹤岗市| 申扎县| 贺州市| 普格县| 湘阴县|