search
HomeBackend DevelopmentPHP ProblemHow to test your own code in php

How to test your own code in php

phpHow to test your own code? Here are several methods to introduce to you:

Violent debugging

This method is simple and crude, and is generally used by PHP programmers, that is, browser debugging. After writing the code in the editor, open the universal browser and enter the address to start debugging the code.

Breakpoint debugging

To be honest, if this method is just to look at the output results, it is completely unnecessary. It seems to be a waste of time and experience, but it is generally I will run debug after the code block is written to check whether the process and results are within my expectations or if I encounter some logical problems that I cannot detect. It is more reliable to choose breakpoint debugging, which saves time and effort. Even the most powerful programmers have moments of confusion, right?

Related recommendations: "php tutorial"

Command debugging

If you download a piece of code from the official website or github Snippet, if you are eager to debug but are not willing to put the code snippet into the project or open a new directory, you can use the php command to execute this code block:

php -f filename.php

If the code snippet is shorter, you can use:

php -r "code ..."

Execute and run PHP code

Fragment debugging

When you suddenly think of a method or algorithm and are eager to verify it, but are unwilling to open the editor Or execute the command line that comes with php. You can choose to use the psysh tool to verify your ideas. The installation of this tool is very simple.

Psy Shell v0.8.17 (PHP 7.1.14 — cli) by Justin Hileman
New version is available (current: v0.8.17, latest: v0.9.6)
>>> date('Y-m-d H:i:s',time())
=> "2018-08-09 14:18:10"
>>>

Download address: https://psysh.org/

Testing and debugging

This is a serious debugging method that many programmers It is considered that the task ends after the development of functional modules and components, and then is handed over to testers for testing. In fact, this is not the case. Some hidden bugs or fatal errors, logic errors, and system errors (such as starting useless threads, unused variables, methods, classes, etc.) cannot be tested. In fact, as a programmer, the process of developing functions is like this.

Understand the requirements -> Decompose the requirements -> Organize the logic -> Design the code -> Type the code -> Debugging -> Test

The above is the detailed content of How to test your own code in php. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment