0

Hallo,

I am trying to understand the nature of using ini_set :

ini_set("SMTP", "smtp.indonusa.net.id");

So if I delete the: SMTP = smtp.indonusa.net.id, will it works? Is it the same thing like writing that code to php.ini?

php.ini

SMTP = smtp.indonusa.net.id

Thanks.

2
Contributors
1
Reply
13
Views
3 Years
Discussion Span
Last Post by cereal
0

No, it's not the same, ini_set affects only the current executed script:

Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.

source: http://php.net/manual/en/function.ini-set.php

Using php.ini is like having an included config file common to all the scripts:

<?php

    require '/app/config.php';

You can do a test, open scriptA.php:

<?php

ini_set('SMTP', 'something.tld');
echo ini_get('SMTP');

# stand by for 60 seconds
sleep(60);

And while the above hangs, open scriptB.php from another tab:

<?php

echo ini_get('SMTP') ? ini_get('SMTP') : 'false';

You can verify they will return two different values. Because scriptB will return the setting in the php.ini file or false if this is missing. And if you're using the mail function somewhere else, it could fail.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.