How to debug PHP code? #824
-
Hello! I am not a professional coder. I learned all myself with tutorials from the internet. So, please be lenient with me :) At the moment I am trying modify the At the moment I write my code into the I am using Ubuntu 20.04 as Desktop with LAMP where Yellow is installed on. I am using VS Code as Code-Editor. Best regards :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello. |
Beta Was this translation helpful? Give feedback.
-
Here are some starting points for debugging source code:
Hope this helps and happy coding. |
Beta Was this translation helpful? Give feedback.
Here are some starting points for debugging source code:
Use a debugger. You are probably used to work with a debugger if you are coming from a programming language like C and C++. You can set break points in your source code, the software stops when it reaches a break point and shows the current variables. You can step trough you source code, line by line and see what happens. It's super comfortable, once you have a debugger set up in your favourite development environment. Have a look at this introduction video for Xdebug.
Use
echo
or similar PHP functions. We all do it from time to time. You can show variables on screen and/or the current web page. It's super quick and a decent too…