Categories > TinyButStrong general >

phpversion<4.2

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Peter
Date: 2003-08-19
Time: 17:15

phpversion<4.2

i have modified the TS to run on older versions.

Where should i post this or nobody need this?

ps: i have tested it, but it can contain errors...

Bye Peter
By: Skrol29
Date: 2003-08-20
Time: 01:18

Re: phpversion<4.2

How whaow !!!!!!

This is often asked.
I had a reseach on that feature but not finished.
I was planning to write an add-in for TBS that provides some PHP>=4.2 functions for PHP<4.2.

How did you do yours ?
I'm interstead with you version even if TBS 1.82 will be available in few weeks.
By: Peter
Date: 2003-08-20
Time: 09:02

Re: phpversion<4.2

i have sent you the file per mail.

Bye Peter
By: moi2002
Date: 2003-08-20
Time: 18:08

Re: phpversion<4.2

Hi Peter and Skrol29,
I am interested in, where do I get the file ?
I promise to try it and check it against PHP 4.1

I think it shoud be of general interest, because a lot of the Apache distros still are running
4.1 version of PHP.

Thanks,
Moises.
By: Peter
Date: 2003-08-21
Time: 11:32

Re: phpversion<4.2

i can send it to you by mail, OK?
By: moi2002
Date: 2003-08-21
Time: 12:14

Re: phpversion<4.2

Hi Peter,
please send it to the address in this posting.

Many thanks,

Moises.
By: moi2002
Date: 2003-08-22
Time: 20:24

Re: phpversion<4.2

Hi Peter and Skrol29,

Peter:
when trying your code I get an error 'undefined function key_exists().......'
Notice that this function is not implemented in PHP 4.1.0, so I added to your code:

if (phpversion()<'4.2.0'){
function array_change_key_case($an_array)
{

//.........bla bla bla........your function......

}

function key_exists($key,$array)
{
        return isset($array[$key]);
}
}

That's for Skrol29:

taken from www.php.net notes:

> sip at email dot ee
>  22-Aug-2003 12:33
> Note, that using array_key_exists() is rather inefficient. The overhead associated with calling a function makes it slower, than using isset($array[$key]), instead of array_key_exists($key, $array)
>  using isset() is usually about 1.3 times faster, according to my tests.

That's why I am ussing 'isset....' instead of 'in_array' that is implemented in PHP 4.1.0

Best Regards,

Moises.

PD: Right now trying TBS on PHP 4.1.0....
By: Peter
Date: 2003-08-25
Time: 14:45

Re: phpversion<4.2

i have changed my lines, so that the function that not exist will be replaced.

if (!function_exists ( array_change_key_case)){
function array_change_key_case($an_array)
{
if(is_array($an_array))
{
foreach($an_array as $key => $value)
$new_array[strtolower($key)] = $value;
return $new_array;
}
else
return $an_array;
}
}
if (!function_exists (key_exists)){
function key_exists($key,$array)
{
return isset($array[$key]);
}
}

Does it work on php 4.1 ?

Thanks for testing
Peter
By: moi2002
Date: 2003-08-25
Time: 19:09

Re: phpversion<4.2

Peter: (I am sending this to your e-mail address too)

Yes, it works on PHP 4.1.0.

Can I suggest to use 'array_key_exists' instead of 'key_exists' as the name of the function implemented ?

That provides 'upwards compatibility' with the original code sent by Skrol29. It's only a matter of a 'general replace' in the code..... :-)

So after this, the code I am using is essentially yours:

if (phpversion()<'4.2.0')
{
if (!function_exists ( array_change_key_case))
{
    function array_change_key_case($an_array)
    {
        if(is_array($an_array))
        {
            foreach($an_array as $key => $value)
                $new_array[strtolower($key)] = $value;
            return $new_array;
        } else return $an_array;
    }
}
if (!function_exists (array_key_exists))
{
    function array_key_exists($key,$array)
    {
        return isset($array[$key]);
    }
}
}

Thanks for all,

Moises.
By: Deane
Date: 2003-08-26
Time: 01:35

Re: phpversion<4.2

Please post or send me by e-mail the modified version that
works under 4.1. Thanks!
By: Peter
Date: 2003-08-26
Time: 08:57

Re: phpversion<4.2

<Can I suggest to use 'array_key_exists' instead of 'key_exists' as the name of the function implemented ?

yes, but i replaced it here all :(

So i hope the next version be compatible with <4.2 :)
By: Peter
Date: 2003-08-26
Time: 08:59

Re: phpversion<4.2

i send you my file per mail

Bye Peter
By: Ariel Graneros
Date: 2003-09-25
Time: 23:43

Re: phpversion<4.2

I need these modifications too. Please send me a copy.
By: Peter
Date: 2003-09-26
Time: 17:06

Re: phpversion<4.2

comment out the check for the php version
and only write this code at the top of the included file:
if (phpversion()<'4.2.0')
{
if (!function_exists ( array_change_key_case))
{
    function array_change_key_case($an_array)
    {
        if(is_array($an_array))
        {
            foreach($an_array as $key => $value)
                $new_array[strtolower($key)] = $value;
            return $new_array;
        } else return $an_array;
    }
}
if (!function_exists (array_key_exists))
{
    function array_key_exists($key,$array)
    {
        return isset($array[$key]);
    }
}
}

Thats all!
If i could read you email adresse i also can send it to you, but i am to lazy to figure out how it is right...

bye Peter
By: Ariel Graneros
Date: 2003-10-01
Time: 18:59

Re: phpversion<4.2

Thanks a lot! It works gracefully with my php4.1.2 (debian).And the email address.. well.. just to avoid some spam.

Great job!