参考:

下载合适的XDebug

点击这里,选择合适xdebug

XAMPP配置

php_xdebug-xxxx.dll

拷贝dll至 D:\XAMPP\php\ext

php.ini

文末追加

[XDebug]
zend_extension = "D:\XAMPP\php\ext\php_xdebug-2.7.0RC2-7.3-vc15.dll"
xdebug.profiler_append =
xdebug.profiler_enable =
xdebug.profiler_enable_trigger =
xdebug.profiler_output_dir = "d:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable =
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log="d:\xampp\tmp\xdebug.txt"
xdebug.remote_port =
xdebug.trace_output_dir = "d:\xampp\tmp"
; ( hour), = 10h
xdebug.remote_cookie_expire_time =
xdebug.idekey="PhpStorm"

Stop/Start Apache

检查xdebug是否安装成功

方法1:运行 http://localhost/dashboard/phpinfo.php 并检查xdebug

方法2:php -m 并检查xdebug

PHPStorm配置

xdebug相应配置

  • 打开phpStorm,进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填localhost,host填localhost,port填80,debugger选XDebug
  • 进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9000,其他默认
  • 进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 PHPSTORM,host 填localhost,port 填80
  • 点OK退出设置

PHPstorm项目配置

指定PHP intepreter

指定项目部署位置

浏览器配置

在适当浏览器上安装插件,这里

以Chrome为例,安装完插件后如图

测试xdebug

实验代码

orderform.html

<html>
<head><title>Bob's Auto Parts</title></head>
<body>
<form action="processorder.php" method="post">
<table border="0">
<tr bgcolor="#cccccc">
<td width="150">Item</td>
<td width="15">Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3"
maxlength="3" /></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3"
maxlength="3" /></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3"
maxlength="3" /></td>
</tr>
<tr>
<td>How did you find Bob's?</td>
<td><select name="find">
<option value = "a">I'm a regular customer</option>
<option value = "b">TV advertising</option>
<option value = "c">Phone directory</option>
<option value = "d">Word of mouth</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order" /></td>
</tr>
</table>
</form>
</body>
</html>

processorder.php

<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results</h2>
<?php
echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
echo '<p>Your order is as follows: </p>';
echo $tireqty.' tires<br />';
echo $oilqty.' bottles of oil<br />';
echo $sparkqty.' spark plugs<br />'; $totalqty = 0;
$totalamount = 0.00; $totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />'; $totalamount = 0.00; define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4); $totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE; echo 'Subtotal: $'.number_format($totalamount,2).'<br />'; $taxrate = 0.10; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />'; ?>
</body>
</html>

调试演示

在PHP中打断点,浏览器触发断点

最新文章

  1. Linux从零单排(一):Google Chrome的安装
  2. JavaScript 常用算法
  3. form表单和ajax表单提交(Html.BeginForm()、Ajax.BeginForm())的差别
  4. 理解JDBC和JNDI
  5. [C/C++]数据类型与变量
  6. FbxDataType is ambiguous
  7. VS2010配色方案
  8. 加密解密,CryptoStream()的使用
  9. Golang下通过syscall调用win32的dll(calling Windows DLLs from Go )
  10. servlet中访问mysql无法包含中文的解决
  11. 关于fsockopen pfsockopen函数被禁用的解决方法
  12. hdu 3405 world islands
  13. 每天一个Linux命令(23)--linux 目录结构(二)
  14. eclipse hibernate导出数据库实体类
  15. npm 一条命令更换淘宝源
  16. wmic 获得系统硬件信息
  17. Elasticsearch系列(5):深入搜索
  18. Java常用类库 读书笔记 一
  19. “对外部(局部)变量的访问”是C语言函数指针的最大弱点
  20. chrome 自动加载flash

热门文章

  1. 深入解读阿里云Redis开发规范
  2. python中实现延时回调普通函数示例代码
  3. cube-ui按钮配合toast单例模式应用
  4. 【Docker学习之二】Docker部署安装
  5. 【ARM-Linux开发】【CUDA开发】NVIDIA TEGRA X1:LINUX驱动程序包多媒体用户指南
  6. JAVA 8 的新特性
  7. JQuery高级(一)
  8. redis的redisvCommand的%b
  9. C++和c语言的区别
  10. C++实现 企业信息管理系统