I have a PHP script that is uploaded to a /fol开发者_开发百科der
It has several pages where uses the mail() function of PHP. I would like to alter the subject eg: [folder] when the mail() function is called from the script that resides in the /folder.
How can I do that?
You can find what folder the current script is in with __DIR__
magic constant
http://www.php.net/manual/en/language.constants.predefined.php
If you use some standard library to send emails, your script might look similar to this.
$folder = end(explode(DIRECTORY_SEPARATOR, __DIR__));
// or dirname(__FILE__) instead of __DIR_ for PHP 5.2
$mail = new Mail();
$mail->addTo('email@example.com')
->subject('['.$folder.'] subject')
->send();
精彩评论