Why do require open file and fwrite cause an error? Warning: fwrite ()

require dirname(__FILE__).'/../logs/log.php'; function addLog($var) { $file = dirname(__FILE__).'/../logs/log.php'; fwrite($file, $var); } 

Closed due to the fact that off-topic participants and , andreymal , terantul , Darth , mymedia Oct 23 '17 at 17:20 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - ߊߚߤߘ, andreymal
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Why cons? What's wrong? If the path is not the correct error should cause require, but it does not cause an error. - Vasya Pupkin
  • fwrite - Binary-safe file write. fwrite () writes the contents of string to the file stream handle. Before fwrite the file first through fopen () open php.net/manual/ru/function.fwrite.php - terantul
  • 2
    This question should be closed, because before asking a question you need to read the documentation on the functions used - terantul

2 answers 2

Cons because you need to start by reading the basics: http://php.net/manual/ru/function.fwrite.php

The fwrite function first parameter requires a link to the resource where the information will be written.

    Forgot $ file = fopen ($ file, 'a');