On 30 March 2010 14:20, Ashley Sheridan <a...@ashleysheridan.co.uk> wrote:
> 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
>
>
>

http://pear.php.net/package/PHP_Compat contains a LOT of userland
functions to allow for forward compatibility of old code.

"PHP_Compat provides drop-in functions and constants for compatibility
with newer versions of PHP, environment emulation, and an API to allow
for version independent authoring."



-- 
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to