php debug debugging tool_PHP tutorial
The project address: php tutorial-debug-tools/">http://freshmeat.net/projects/php-debug-tools/
File download address: http://freshmeat.net/urls/7c58ae3fecce5763e7546b958d36e082
Currently version 1.03
The environment here is window xp, apache2.2, php5.2+ zend optimizer,
This is explained in conjunction with the help documentation of php debug tools. Some of the pictures are excerpted from the documentation.
1. Installation
Preparation environment before installation: x-debug must be installed first,
As for how to install x-debug, please see http://www.xdebug.org/docs/install
1. Download the appropriate x-debug version from http://www.xdebug.org/download.php
2. Unzip the dll file to the ext directory under the PHP installation directory, such as c:/php/ext/php_xdebug-2.0.4-5.2.8-nts.dll
3. Modify the php.ini file and add the following paragraph:
-------------I am the dividing line of perversion, you can’t see me--------------------------
zend_extension = "c:/php/ext/php_xdebug-2.0.4-5.2.8-nts.dll"
xdebug.collect_includes = off
xdebug.default_enable = off
xdebug.dump_globals = off
xdebug.dump_once = off
xdebug.extended_info = off
-------------I am the dividing line of perversion, you can’t see me--------------------------
Note: this example is for non-thread safe version. for the thread safe version change "zend_extension" to "zend_extension_ts"
After the installation is complete, unzip all the files in the php debug tools compressed package to the website publishing directory.
(Assuming the release directory is c:www, then create a new debug directory in it and throw all the files into it)
Enter in the browser: http://localhost/debug/test1-debug.php
If you see the picture below, the installation is successful.
2. Debugging
1.debug errors
Such as the following code:
Copy the code. The code is as follows:
require './lib/debug.php';
function test($a, $b)
{
echo $asd;
}
test(10, 'abc');
?>
2. Use debug() to debug
Such as the following code:
Copy the code. The code is as follows:
require './lib/debug.php';
function test($args)
{
test_nested($args);
}
function test_nested($args)
{
debug($args);
// or: debug(get_defined_vars());
// or: debug();
}
test(array('id'=>123, 'str'=>'test'));
?>
3. Use dump() or dump_tofile() to debug
Such as the following code:
Copy the code. The code is as follows:
include_once './lib/dump.php';
function test5()
{
include './testdata/test0.php';
$test = array('int'=>1, 'float'=>2.0, 'float2'=>2.1);
dump($test, $_server);
}
function test1() { test2(); }
function test2() { test3(); }
function test3() { test4(); }
function test4() { test5(); }
test1();
?>
As for dump_tofile(), it is generally used in the following situations:
a. When you don’t want to stop the program from running
b. It’s not that you don’t want to display debug data, but that you can’t. For example, when you request status in ajax.
c. You also want to adjust the style in multiple places
Please refer to test7-dump_tofile.php
in the debug directoryNote: When I ran dump() or dump_tofile(), I found that the php debug tool documentation did not appear
This can be corrected by modifying the code of debug/lib/debug.php. (Because dump_tofile() calls dump(), we only need to modify one place.
at line 149
echo $pre;
was changed to:
//edit by benben---start
echo '';
//edit by benben---end
Corrected picture:
4. Track code and check system performance
You can browse test3-trace.php in the directory, and then click the console in the lower right corner.
For details, please refer to the documentation. (The documentation is in the doc directory in the compressed package)
3. How to combine it with the project?
First unzip the php debug tool file and place it in the project directory. Create a directory and call it debug! : )
In fact, all we need is a few files.
For example, the path is: c:wwwprojectnamedebug
After that, we can debug in two ways
The first way is to add this sentence to the project source code:
include_once('./lib/debug.php');
For example: c:wwwprojectnamehellodebugindex.php
Copy the code. The code is as follows:
include_once('./debug/lib/debug.php');
$faint = 'helloworld ,debuging';
debug($arrb);
?>
What? You don’t want to write this sentence on every page?
Then take a look at the second method,
There are two ways here,
1. Modify php.ini and add the following content (modify to your own directory):
auto_prepend_file = "c:wwwprojectnamedebugauto_prepend.php"
auto_append_file = "c:wwwprojectnamedebugauto_append.php"
2. Modify the .htaccess file (Note: I have never tried this method, hehe)
php_value auto_prepend_file "c:wwwprojectnamedebugauto_prepend.php"
php_value auto_append_file "c:wwwprojectnamedebugauto_append.php"

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

AI Hentai Generator
Generate AI Hentai for free.

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



PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

The readdir function in the Debian system is a system call used to read directory contents and is often used in C programming. This article will explain how to integrate readdir with other tools to enhance its functionality. Method 1: Combining C language program and pipeline First, write a C program to call the readdir function and output the result: #include#include#include#includeintmain(intargc,char*argv[]){DIR*dir;structdirent*entry;if(argc!=2){

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

Website performance optimization is inseparable from in-depth analysis of access logs. Nginx log records the detailed information of users visiting the website. Cleverly using this data can effectively improve the speed of the website. This article will introduce several website performance optimization methods based on Nginx logs. 1. User behavior analysis and optimization. By analyzing the Nginx log, we can gain a deep understanding of user behavior and make targeted optimization based on this: High-frequency access IP identification: Find the IP address with the highest access frequency, and optimize the server resource configuration for these IP addresses, such as increasing bandwidth or improving the response speed of specific content. Status code analysis: analyze the frequency of different HTTP status codes (such as 404 errors), find out problems in website navigation or content management, and proceed

The steps to install an SSL certificate on the Debian mail server are as follows: 1. Install the OpenSSL toolkit First, make sure that the OpenSSL toolkit is already installed on your system. If not installed, you can use the following command to install: sudoapt-getupdatesudoapt-getinstallopenssl2. Generate private key and certificate request Next, use OpenSSL to generate a 2048-bit RSA private key and a certificate request (CSR): openss

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

In Debian systems, OpenSSL is an important library for encryption, decryption and certificate management. To prevent a man-in-the-middle attack (MITM), the following measures can be taken: Use HTTPS: Ensure that all network requests use the HTTPS protocol instead of HTTP. HTTPS uses TLS (Transport Layer Security Protocol) to encrypt communication data to ensure that the data is not stolen or tampered during transmission. Verify server certificate: Manually verify the server certificate on the client to ensure it is trustworthy. The server can be manually verified through the delegate method of URLSession
