- 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.
- 機器學習系統:設計和實現
- 軟件項目管理(第2版)
- Learning Docker
- Learning Elixir
- SQL Server 2012數據庫管理與開發項目教程
- Mastering C++ Multithreading
- 從零開始學Android開發
- Visual Basic 程序設計實踐教程
- Mastering Leap Motion
- 量子計算機編程:從入門到實踐
- Mastering Object:Oriented Python(Second Edition)
- 計算機程序的構造和解釋(JavaScript版)
- 青少年Python趣味編程
- Spring Boot學習指南:構建云原生Java和Kotlin應用程序
- PHP程序設計高級教程