Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:41:39+00:00 2026-06-10T21:41:39+00:00

My code: function log_this($to_log, $prepend = null){ ob_start(); $fn = ‘../info.log’; $fp = fopen($fn,

  • 0

My code:

function log_this($to_log, $prepend = null){

    ob_start();
    $fn = '../info.log';        
    $fp = fopen($fn, 'a');

    fputs($fp, "\r\rnew log -------- \r\r");

    if(isset($prepend)) fputs($fp, $prepend . ":\r\r");

    var_dump($to_log);
    $content = ob_get_contents();

    fputs($fp, $content);
    fclose($fp);
    ob_end_clean();
}

It’s a function I always use in my local environment (MAMP) to log things from wordpress.
it always worked. Now it doesn’t work anymore. I tried to understand why for a couple of days but can’t find any solution. I’m not a really advanced php programmer, so maybe there’s something I don’t know and should.. Can anyone help me please?

By the way, function_exists and also file_exists, from where I call it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:41:40+00:00Added an answer on June 10, 2026 at 9:41 pm

    I’m not sure why fputs isn’t working, it is probably to do with your servers folder permissions (usually 0755 or 0775 is safe), could also add a condition to check is_writable to eliminate that possibility. Have you tried using file_get_contents and file_put_contents.

    define('FILE_PATH', 'path/to/file/file.log'); 
        function log_this($command, $array = null) {
        //check if we can get to the file
        if(file_exists(FILE_PATH)){
        $current = file_get_contents(FILE_PATH);
        $current .= $command;
        if(!is_null($array)){
        ob_start();print_r($array);$output = ob_get_clean();
        $current .= $output;
        }
        file_put_contents(FILE_PATH, $current);
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: function Keyboard() { this.log = $('#log')[0]; this.pressedKeys = []; this.bindUpKeys
Consider this code: var img = new Image(); img.onload = function() { console.log(this.width); };
I have this code App.Model('users').find(function (err, users) { users.forEach(function(user) { console.log(user.username); }); }); //make
this is my code and have a error: $('#map_canvas').mouseover(function(e){ console.log(e.offset().left+' '+e.offset().top) }) thanks i
In the js code specified below - var tclass = function(){ this.func2=function(){console.log('func2')}; this.b={ func1:
I have this code inside a iframe: window.addEventListener('message', function(e){ if(e.data == 'test') console.log(e); },
Consider the following code: $(window).unload(function () { console.log('foo'); }); If I trigger the unload
Here is my jquery code: $('input').click(function(){ $('h1').empty().queue(function(){ console.log('queue'); }); }); }); Only the first
Here is my code: var showNo = 1; window.setInterval(function() { console.log(showNo); if(showNo === 1)
My code: myobj = new Object(); classes.testegy = Class.extend({ init: function (token) { console.log(test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.