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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.