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)); 

0 0 vote
Article Rating
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x