How to Write Debugging Output to Log File in PHP
The below code shows you how to write debugging output to a log file in PHP using error_log
function.
- Write a primitive data type:
example.php
<?php
$data = 'Message for debugging';
error_log($data);
- Write an object or array data type:
example.php
<?php
$users = array(
'David',
'Kai',
'Ivan'
);
error_log(print_r($users, TRUE));