How to output data to console (console.log) in PHP?
Hello everyone! I just started learning PHP after JavaScript, and I have a problem. In JS I'm used to using console.log() for debugging — it's very convenient: you write it anywhere in the code and see the result in the browser console. But in PHP I can't find an equivalent.
I tried echo and var_dump, but they output data directly into the HTML code of the page. This breaks the layout and is inconvenient when you need to check a variable's value inside a loop or function, especially if the script runs in the background (for example, when processing an AJAX request or in a CLI script).
Here's an example of my code:
```php
```
No answers yet.
Log in to leave an answer