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

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.

主站蜘蛛池模板: 嘉黎县| 黄陵县| 凉山| 科尔| 库车县| 天津市| 萨迦县| 镇康县| 湘乡市| 蓬溪县| 曲沃县| 拜城县| 英德市| 海口市| 石首市| 定襄县| 斗六市| 盐源县| 伊春市| 丹江口市| 台南县| 垦利县| 四川省| 天祝| 阳城县| 瑞安市| 珲春市| 年辖:市辖区| 安乡县| 合作市| 扬中市| 邹平县| 汶川县| 奇台县| 卢湾区| 连平县| 漯河市| 芜湖市| 呼玛县| 磐安县| 镶黄旗|