On Tue, 2010-03-30 at 16:16 +0300, Andre Polykanine wrote:
> Hello everyone,
> Sorry, I've forgotten how to do this...
> I need a quoted_printable_encode function but it's available only
> since PHP 5.3. How do I redefine that function only if PHP version is
> lower than 5.3?
> Would it be valid:
> function quoted_printable_encode ($str) {
> $x=quoted_printable_encode ($str);
> if (!isset($x)) {
> // blah blah, alternative code
> } else {
> return $x;
> }
> }
> Is it valid code or not?)
> Thanks!
>
>
> --
> With best regards from Ukraine,
> Andre
> Http://oire.org/ - The Fantasy blogs of Oire
> Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
> jabber.org
> Yahoo! messenger: andre.polykanine; ICQ: 191749952
> Twitter: http://twitter.com/m_elensule
>
>
The custom way is to use function_exists() to check to see if the
function exists:
if (!function_exists('quoted_printable_encode'))
{
function quoted_printable_encode()
{
your code to replicate the functionality here
}
}
Then, you can call quoted_printable_encode safe in the knowledge that
there will always be a definition for it.
Thanks,
Ash
http://www.ashleysheridan.co.uk