When you want to debug certain sections of code with in an environment without restarting Apache or NGINX, there’s a template I use for displaying print messages.
echo "<pre>".json_encode($VALUE, JSON_PRETTY_PRINT)."</pre>";
Sometimes when you are using php you need to change some of the settings, this can be done by using the ini file.
Before you change anything in the ini file you should check the phpinfo. This can be done by creating a file containing
<?php phpinfo(); ?> and then navigating to the path for that file in a browser.
Once you have confirmed where the php ini file is, make your changes. To apply these changes you will have to restart apache. The code to do this depends on which platform you are running. One of the common ones can be done by
systemctl restart apache2. Hope this helps someone.
There isn’t very many differences they both can be used to output to the page, however print also returns a 1.
$_POST doesn’t always get you what you need. If you are passing in JSON as the body of a request, you can’t get it using $_POST. You will have to use
file_get_contents('php://input');. I found this to be extremely annoying and not well documented.