[RESOLVED] PHP 6 global
Results 1 to 5 of 5

Thread: [RESOLVED] PHP 6 global

  1. #1
    Member
    Join Date
    Oct 2009
    Posts
    47

    resolved [RESOLVED] PHP 6 global

    Hi all. I looked for a solution on the web, but couldn't find it. Can someone tell me if this will still work in PHP 6:

    Code:
    function main() {
    global $varone, $vartwo;
    ...php code
    }
    ?>
    I read that some global function are removed for the sake of security.
    Thank you.

  2. #2
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,986
    To the best of my knowledge, global is not going away (and probably never will, since so much existing code depends on it). That being said, I would still try to get rid of it from your code, as it is generally frowned upon due to the way it tightly couples the function to the application and tends to hide the function's dependencies and side-effects.
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because hes a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  3. #3
    PHP Witch laserlight's Avatar
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    13,593
    Quote Originally Posted by prkarpi
    I read that some global function are removed for the sake of security.
    You might be thinking of the currently deprecated register_globals option being removed for the sake of security.
    Use Bazaar for your version control system
    Read the PHP Spellbook
    Learn How To Ask Questions The Smart Way

  4. #4
    Member
    Join Date
    Oct 2009
    Posts
    47
    Well, both of your answers suit me - thank you. I know PHP 5 needs $_GET or $_POST for the vars - I learned that from coming from PHP 4 and had to replace many pages of coding. But my question was about function() and declaring the vars with "global."

    My question is this then for NogDog - what is the other way to declare vars within function() parameters - i.e. not using "global."

    Thank you.

  5. #5
    PHP Witch laserlight's Avatar
    Join Date
    Apr 2003
    Location
    Singapore
    Posts
    13,593
    Quote Originally Posted by prkarpi
    what is the other way to declare vars within function() parameters - i.e. not using "global."
    Pass them as arguments, possibly by reference if necessary.
    Use Bazaar for your version control system
    Read the PHP Spellbook
    Learn How To Ask Questions The Smart Way

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •