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

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.

主站蜘蛛池模板: 康定县| 定西市| 通渭县| 昌图县| 平舆县| 贵溪市| 新田县| 延川县| 龙里县| 灵山县| 宝丰县| 杨浦区| 罗源县| 东宁县| 探索| 哈巴河县| 正宁县| 安陆市| 常州市| 武邑县| 西城区| 岐山县| 天门市| 达尔| 彭州市| 建平县| 乐至县| 广州市| 教育| 嘉鱼县| 威宁| 湘阴县| 甘肃省| 澄江县| 嘉兴市| 泗洪县| 江北区| 桓仁| 都安| 泰州市| 芦溪县|