Question

Hello everyone,

I was wondering if there any way to access a predefined variable like this..

define("EVENT_LOG", "../app_logs/log.log");

function Log($string)
{
   $fileHandler = fopen( constant("EVENT_LOG"), 'w') or die('sCannot open file:  '.constant("EVENT_LOG"));
   ....
   ..
}

I keep getting the below error message:

fopen(../app_logs/log.log): failed to open stream: ...

Any ideas what could be wrong? To me it looks as if the predefined variable was not returned as a string (??)

Thanks in advance, Alex

Was it helpful?

Solution

Be sure that you check that your path is correct and try:

<?php
define("EVENT_LOG", "../app_logs/log.log");
function Log($string)
{
   $fileHandler = fopen( EVENT_LOG, 'w') ;
   return $fileHandler;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top