Three different topics, perhaps suited to three seperate emails, but I'll
cover them all in one.

Firstly, something regarding accessing form/query string variables, on
diffferent versions of PHP. Starts to become a nightmare, but you also want
to make sure you _aren't_ requiring register_globals to be on...

so what I do;

function Form($var = null)
{
    if (function_exists('version_compare')) // added in 4.1.0
    {
        return @$_POST[$var];
    }
    global $HTTP_POST_VARS;
    return @$HTTP_POST_VARS[$var];
}

then just

$variable = Form('field');

you can adapt the code for the other various http variable arrays etc. I
have encapsulated it in a class, and also, to remove the call to the
function_exists function every time I attempt to get variable

define('MY_PHP_VERSION', function_exists('version_compare'));

then the if statement becomes if (MY_PHP_VERSION) {




Now, a couple of other things to discuss.

can anyone else confirm my conclusion;

define('MYSTRING', 'Hello World');
for ($i = 0; $i < 5000; $i++) { echo MYSTRING; }

class Msg { function MyString() { return 'Hello World'; } }
for ($i = 0; $i < 5000; $i++) { echo Msg::MyString(); }

that creating a static class, with static members, and calling those,
instead of using define() variables, is actually faster?



thirdly,

for ($i = 0; $i < 5000; $i++) { echo $i; }

$i = 5000; while ($i--) { echo $i; }

that the decrementing while loop is actually faster than a for loop?

btw I'm aware that a decrementing while loop can not be a replacement for
every for loop situation, but there are times when you can use it instead,
and from what I can see, its faster.



Hope I made sense. I'm in a rush! Also my first post to the list for about 4
years! These things could have been discussed already so I apologise, just
in case.

Regards,

Sean




///////////////////////////////////////////////////////////////////
// Sean Malloy
// Developer
// element
// e: [EMAIL PROTECTED]
// t: +61 3 9510 7777
// f: +61 3 9510 7755
// m: 0413 383 683
///////////////////////////////////////////////////////////////////

DISCLAIMER:
© copyright protected element digital pty ltd 2002.
the information contained herein is the intellectual property
of element digital pty ltd and may contain confidential material.
you must not disclose, reproduce, copy, or use this information
in any way unless authorised by element digital pty ltd in writing
or except as permitted by any applicable laws including the
copyright act 1968 (cth).


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

Reply via email to