p2p.wrox.com Forums

Need to download code?

View our list of code downloads.

  Return to Index  

beginning_php thread: RE: Wrox search engine sucks [was [RE: super simple login trouble [ was [ RE: i need simple logout [was RE: variable doesn't show up in $_COOKIE or $HTTP_COOKIE_VARS or $_

Message #1 by "Nikolai Devereaux" <yomama@u...> on Wed, 26 Feb 2003 11:28:58 -0800
> Once again, I wish you kept an online archive. The search engine
> that Wrox uses on the P2P site is really quite bad - it doesn't
> seem to keep track of names or email addresses. I tried these searches:

I never use the p2p search engine.  I use google.

Example searches:

 site:p2p.wrox.com devereaux
 site:p2p.wrox.com devereaux TIP
 site:p2p.wrox.com devereaux FAQ
 site:p2p.wrox.com devereaux register_globals FAQ

> The first four came back empty, the 5th one had 35 responses, all
> from ASP and Java boards, nothing from the PHP boards. Some
> search engines are so bad that I don't know why people use them.
> I wish Google would drop its prices so that every company could
> afford to license them.

Because of google's "site search" feature, p2p doesn't actually need to
license the search software from google (or buy their search appliance).
See above. =)

> Anyway, there was a post you made last year that was a real
> masterpiece, on the subject below, of superglobals, but I've lost
> it and I'm wondering if your email client kept a copy.
> The exchange went something like this: you said I should switch
> to the new superglobals, I said I needed backwards compatibility,
> and then you came back with a function that first checked for the
> presense of the old HTTP_VARS and then checked for the presense
> of the $_GLOBALS. It was a real elegant piece of code, as I
> remember it. Do you remember what I'm talking about?

Hmmm... it sounds familiar.  Try this:

<?php // register_globals.php

function register_globals()
    $globals_order = array('ENV', 'GET', 'POST', 'COOKIE', 'SESSION');

    foreach($globals_order as $global)
        $sgname = "_$global";  // superglobal name, e.g. _GET, _POST
            $sg = &$GLOBALS[$sgname]; // is a reference to actual
            foreach($sg as $key=>$value)
                $GLOBALS[$key] = $value;  // global is a *copy*


To use this, simply require_once() this file at the top of any script that
needs register_globals="on" functionality:

<?php  some_page.php




Hope this helps!


  Return to Index