I want to rewrite a function in PHP (let's say the mail() function), and want to make it so when I call mail() from now on, it will load my version of mail() and not the default php version. Is this possible in php?
The reason I want to do this is because I have thousands of lines of code which call mail() and I don't want to rewrite all of them.
Also for future reference, in computer programming, what is it called when you do something like this?
to check if it is sending mail as intended; <? php $email = "[email protected]"; $subject = "Email Test"; $message = "this is a mail testing email function on server"; $sendMail = mail($email, $subject, $message); if($sendMail) { echo "Email Sent Successfully"; } else { echo "Mail Failed"; } ?>
PHP makes use of mail() function to send an email. This function requires three mandatory arguments that specify the recipient's email address, the subject of the the message and the actual message additionally there are other two optional parameters. mail( to, subject, message, headers, parameters );
A function is a piece of code that takes another input in the form of a parameter, processes it, and then returns a value. A PHP Function feature is a piece of code that can be used over and over again and accepts argument lists as input, and returns a value. PHP comes with thousands of built-in features.
There is an extension that allows you to override functions. It is meant to be used for debugging, but I guess you can use it for your needs. Take a look:
http://www.php.net/manual/en/function.override-function.php
If you wish to call the original function within your version, make sure you read this comment: http://no.php.net/manual/en/function.override-function.php#50821
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With