第一次接触php是在2014-5月份左右,当时是自己的主攻方向是C#,对php比较排斥, 其中很多一部分原因,就是PHP的断点调试一直无法配置成功,用echo打印日志的方式排错,使得自己对php心生怨恨,而错失了深入学习php的好机会。这次写这篇随笔,一方面是记录自己php方向的起航,另一方面也是希望能帮助刚接触php的初学者么,能够顺利的配置php的环境,而不至于对php产生恐惧。
一、系统环境简介
Windows系统是一个非常常见的系统。相信这里也不用多做解释。那么如何开启IIS(win8.1),其实网上已经有很多教程,我这里只做简单的介绍。
①安装.net fromework 3.5
IIS运行需要依赖.net3.5,因此第一步就是安装.net fromework3.5。安装方法大致有两种,一种是在线下载,速度非常慢(真的非常慢),这里给大家介绍第二种,离线安装.net fromework3.5。找到安装win8的iso文件,加载到虚拟光驱中,如果有刻U盘系统的插入U盘即可。运行 “命令提示符(管理员)”(右键桌面的Win图标),输入命令“dism.exe /online /enable-feature /featurename:NetFX3 /Source:V:\sources\sxs”,V盘表示虚拟光驱的盘符或U盘的盘符。
②开启IIS
做开发的,开启IIS应该是小case了。这里就不多说了。
二、预先工作
①环境及IDE等文件下载
以下为参考网址,如无法打开或变动,请自行搜索,获取最新版本文件请行搜索,以下链接版本日期:2015-4-29最新
PHPManager:http://www.iis.net/downloads/community/2010/09/php-manager-for-iis-7
PHP:http://windows.php.net/download
XDebug:http://xdebug.org/
PHPStrom:http://www.jetbrains.com/phpstorm/
Xdebug Helper:http://www.chromein.com/crx_11294.html
②安装
初始的IIS是不支持php的,所以我们先下载了PHP Manager这个工具,安装成功后,可以在IIS中看到php manager的图标,如下图:
进入php manager。后续配置比较简单,请自行百度,本文文的重点是讲断点调试,所以就不多啰嗦了。php配置完成后会看到如下界面:
将下载下来xdebug的解压文件复制到php目录的ext文件夹中
接下来就是IDE的安装了,PHPStorm安装还是很简单的,这里也不做多说,Xdebug helper是Chrome的一个扩展工具,在浏览器中输入chrome://extensions/,然后将下载下来的crx文件拖入该页面就可以了。
三、配置
①Xdebug
Xdebug的配置网上一搜一大片,这里只给出我的配置,在php.ini文件中,加入以下代码,注意其中几个文件的位置。
[Xdebug] ;xdebug配置 zend_extension="D:/php/php-5.6.8-nts-Win32-VC11-x64/ext/php_xdebug-2.3.2-5.6-vc11-nts-x86_64.dll" ;载入Xdebug xdebug.idekey="PHPSTORM" xdebug.profiler_enable=on xdebug.trace_output_dir="D:/php/xdebug-log" ;xdebug 的数据文件目录 xdebug.profiler_output_dir="D:/php/xdebug-log" ;xdebug 的数据文件目录 xdebug.auto_trace = On ;开启自动跟踪 xdebug.show_exception_trace = On ;开启异常跟踪 xdebug.remote_autostart = Off ;开启远程调试自动启动 xdebug.remote_enable = On ;开启远程调试 xdebug.remote_handler=dbgp ;用于zend studio远程调试的应用层通信协议 xdebug.remote_host=localhost ;允许连接的zend studio的IP地址 xdebug.remote_port=9001 ;反向连接zend studio使用的端口 xdebug.collect_vars = On ;收集变量 xdebug.collect_return = On ;收集返回值 xdebug.collect_params = On ;收集参数 xdebugbug.max_nesting_level = 10000 ;如果设得太小,函数中有递归调用自身次数太多时会报超过最大嵌套数错
②PHPStorm
进入php设置
选择php语言设置
添加解释器,其实如果你在IIS中运行,是不用添加解释器的,不过如果直接通过phpstorm来打开你的php代码则需要添加解释器,如下,按Alt+F2。通过解释器运行php,是不需要安装IIS的
接下来就是配置phpStorm的debug了。其实phpstorm的debug基本都有默认设置了,但我们最好还是要修改一下,因为可能9000端口被其他应用占用了。所以我们需要更改为其他端口,例如9001
注意:这里的端口要与php.ini中xdebug中的端口配置一致,请看上面的配置代码。
xdebug.remote_port=9001 ;反向连接zend studio使用的端口
③xdebug helper
它是Chrome的一个插件,真的很好用,配置很简单,直接上图
到这配置基本结束了。下面我们测试一下。
四、断点调试测试
①找到页面,开启调试,点击小虫,选择Debug。
②PHPstorm开启监听
刷新http://localhost/php/FirstPHP.php页面
运行结果:
结果运行正确,到此本篇文章也就结束了,希望能对观者有所帮助。
以上所述就是本文的全部内容了,希望大家能够喜欢。

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

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