PHP在浏览器上追踪调试的方法以及使用ChromePhp的简单介绍
PHP在浏览器上跟踪调试的方法以及使用ChromePhp的简单介绍
之前用ThinkPHP时发现有个 trace 函数可以跟踪调试,感觉很有意思,网上搜索了下类似的东西,发现了 ChromePhp ,以前没想过这样来调试 PHP 程序,感觉非常方便,很有用。
ThinkPHP 使用的是自己生成的 HTML 随模版一起输出来显示,偶尔会遇到一些莫名其妙的问题,效果不是太好,
还有一些也是类似的方法,但输出的主要是在模版中增加 JS 代码,调用浏览器的调试方法进行输出调试
如 console.log('PHP的一些调试输出内容');
ChromePhp 是通过header来传输调试内容并通过安装 Chrome 浏览器的插件读取header 信息显示到浏览器调试面板中进行查看,功能比较强大,对页面没什么太多干扰,调试也更方便,火狐下据说也有类似的 firePhp ,不过现在不怎么用火狐浏览器也没去测试过
官网地址:
http://www.chromelogger.com/
这是该开源项目的 Github 地址:
Github : https://github.com/ccampbell/chromephp
这是 Chrome 内核浏览器插件的安装地址:
https://chrome.google.com/extensions/detail/noaneddfkdjfnfdakjjmocngnfkfehhd
不过老是被墙,不容打开,而且只能是 google chrome 才能安装,我找了老半天只找到个 3.0 的插件
插件下载地址:
http://download.csdn.net/detail/zsjangel/7535201
可以安装后试试 升级到现在最新的 4.1,我是这样成功了的
3.0 的插件图标和 4.1 的不一样的:
下面是4.1版本,黑色表示为开启插件,点击启动
下方显示蓝色时表示启动,可以在面板中看到调试信息
PHP下的使用方法:
ChromePhp::log('Hello console!');ChromePhp::group('this is group');ChromePhp::log('Hi 神神的蜗牛!');ChromePhp::error('something went wrong!');ChromePhp::groupEnd();ChromePhp::table(array(array('aa'=>'bb', 'cc'=>11), array('aa'=>'cc', 'cc'=>22)));
group 表示下面的所有都是一组调试信息,一直到 groupEnd 结束,显示效果和普通的 log 是不一样的
table 的参数必须是 二维数组,否则将不显示,数组的键名及字段名
下面是效果图:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Every application you run on Windows has a component program to update it. So if you are using Google Chrome or Google Earth, it will run a GoogleUpdate.exe application, check if an update is available, and then update it based on the settings. However, if you no longer see it and instead see a process updater.exe in the Task Manager of Windows 11/10, there is a reason for this. What is Updater.exe in Windows 11/10? Google has rolled out updates for all its apps like Google Earth, Google Drive, Chrome, etc. This update brings

Chrome's inability to load plug-ins can be solved by checking whether the plug-in is installed correctly, disabling and enabling the plug-in, clearing the plug-in cache, updating the browser and plug-ins, checking the network connection, and trying to load the plug-in in incognito mode. The solution is as follows: 1. Check whether the plug-in has been installed correctly and reinstall it; 2. Disable and enable the plug-in, click the Disable button, and then click the Enable button again; 3. Clear the plug-in cache, select Advanced Options > Clear Browsing Data, check cache images and files and clear all cookies, click Clear Data.

What is the Chrome plug-in extension installation directory? Under normal circumstances, the default installation directory of Chrome plug-in extensions is as follows: 1. The default installation directory location of chrome plug-ins in windowsxp: C:\DocumentsandSettings\username\LocalSettings\ApplicationData\Google\Chrome\UserData\Default\Extensions2. chrome in windows7 The default installation directory location of the plug-in: C:\Users\username\AppData\Local\Google\Chrome\User

What should I do if the Google Chrome web page cannot be opened? Many friends like to use Google Chrome. Of course, some friends find that they cannot open web pages normally or the web pages open very slowly during use. So what should you do if you encounter this situation? Let’s take a look at the solution to the problem that Google Chrome web pages cannot be opened with the editor. Solution to the problem that the Google Chrome webpage cannot be opened. Method 1. In order to help players who have not passed the level yet, let us learn about the specific methods of solving the puzzle. First, right-click the network icon in the lower right corner and select "Network and Internet Settings." 2. Click "Ethernet" and then click "Change Adapter Options". 3. Click the "Properties" button. 4. Double-click to open i

GitHubCopilot is the next level for coders, with an AI-based model that successfully predicts and autocompletes your code. However, you might be wondering how to get this AI genius on your device so that your coding becomes even easier! However, using GitHub isn't exactly easy, and the initial setup process is a tricky one. Therefore, we created this step-by-step tutorial on how to install and implement GitHub Copilot in VSCode on Windows 11, 10. How to install GitHubCopilot on Windows There are several steps to this process. So, follow the steps below now. Step 1 – You must have the latest version of Visual Studio installed on your computer

This article is about learning Gitlab, talking about how to set up a protected branch and submit a PR to your leader. I hope it will be helpful to everyone!

Chrome means browser, a web browser developed by Google. It was first released in 2008 and quickly became one of the most popular browsers in the world. Its name comes from the browser's interface design because of its iconic The feature is the tab bar at the top of the window, and the appearance of this tab bar is very similar to chrome metal.

This tutorial shows you how to find specific text or phrases on all open tabs in Chrome or Edge on Windows. Is there a way to do a text search on all open tabs in Chrome? Yes, you can use a free external web extension in Chrome to perform text searches on all open tabs without having to switch tabs manually. Some extensions like TabSearch and Ctrl-FPlus can help you achieve this easily. How to search text across all tabs in Google Chrome? Ctrl-FPlus is a free extension that makes it easy for users to search for a specific word, phrase or text across all tabs of their browser window. This expansion
