What is the relationship of HTTP headers and directory with destructors in php? -


i know destructor in php oop 1 thing want know relationship of http headers , directory destructor in php ?

can tell mean ?

destructors called during script shutdown have http headers sent. working directory in script shutdown phase can different sapis (e.g. apache).

this documented in destructor in reference link below.

http://php.net/manual/en/language.oop5.decon.php

that attempts explain when destructor called headers_sent() return true , gives heads working directory might different when destructor called(it may not same how during constructor or when other methods called)(typically working directory script lives). work around use absolute path or use chdir();

so need careful when doing actions following:

class files{      function __destruct() {           unlink($this->logfile); // may wrong if relative path     }     } 

going first part, when destructors called, headers sent. won't able things depend on "header sent". example, redirect or initializing session.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -