Question

I wanna know where is the best place to put the ini_set() functions, because I think when the ini_set function is inside the method like this:

private function archiveBackup() {
    ini_set('memory_limit', '128M');
    ini_set('max_execution_time', 0);
    ...
}

The ini_set function doesn't work?!

My script works like that: jQuery ajax query -> ajax.php file (make instance of the class and call some method) -> call the method of the class.

Where is the best place? In ajax.php file or at the start of class or inside methods?

Était-ce utile?

La solution

In general, the best place to put ini_set calls is right at (or near) the start of the script. That way, it's pretty much the same as if they had been defined in the php.ini file in the first place.

Autres conseils

I have noticed you have placed ini_set at the start of your main function which is most likely correct.

So:

The ini_set function doesn't work?!

Could be because your shared hosting provider has permission blocked you in some manner.

As Kolink says, it is likely the hosting provider is using disable_functions on you.

Might be considered as a personal preference but I personally avoid using any kind of PHP configuration directives outside of my application configuration files. In other words if a certain class of my project requires specific PHP run-level configuration I note that requirement in the class description but still apply the configuration itself in my main configuration files.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top