0

I need to call PHP function within my custom module controller. But the relevant PHP file contain in different folder. How I solve this? `

<?php function doLog($text) { 
// open log file
$filename = "form_ipn.log";
$fh = fopen($filename, "a") or die("Could not open log file.");
fwrite($fh, date("d-m-Y, H:i")." - $text\n") or die("Could not write
file!");
fclose($fh);
}
doLog("This is test");
?>  
3
  • Can you please be more specific? Is the code in a PHP class? What kindof classis? Model or Helper? Commented Feb 26, 2016 at 12:16
  • @RiccardoT No this is just a PHP file that containing function to write/append log file. Path for the file magento->testing->test.php. I have updated my question with code.
    – Dis_Pro
    Commented Feb 27, 2016 at 3:21
  • Why on earth are you doing this in the first place? Use the logging functionality provided in magento framework
    – ProxiBlue
    Commented Feb 27, 2016 at 5:33

1 Answer 1

1

You can mention URL like $url = 'http://127.0.0.1/magento/testing/curl.php'; or you should get base directory like $media_path = Mage::getBaseDir('media'); or you can redirect to relevant URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.