Scope of the variable in more than one php file

Discussion in 'PHP' started by Harish kumara, May 18, 2009.

  1. #1
    hi fnds am new one to use php,I' am doing a small project which includes 5 php files the problem is all php files need one data ie object written by the client login for google docs now I need to make that object available to all the 5 files untill user quits the project is there any scope facility in php to make a variable to be accessible by any file????

    thank you,
     
    Harish kumara, May 18, 2009 IP
  2. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #2
    use like this at top of ur page

    global <variable name>

    then u can use that variable any where in the page like


    global <variable name>
    inlcude "page1.php"
    inlcude "page2.php"
    inlcude "page3.php"


    the <variable name> will be availble to all files
     
    octalsystems, May 18, 2009 IP
  3. Harish kumara

    Harish kumara Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    :(I think you did'nt get my problem clearly right???? k I'll explain you in detail
    see am using extjs framework to build client side and php to build server side jobs...
    Now I have a script1.js file that have a button "retrieve files" whenever I click that button it should list out the file names...

    I have loging.php file
    functions: 1. login to googledocs.
    2.get the docs object through which we can retrieve
    the uploaded files.
    this file should be called only once that is at the begining of the project where login requires.

    another file retreive.php
    functions: It takes care about retrieve the files name and retruns those to script.js file to display.
    Here to get the files it needs to use the 'docs' object which is created
    in the file loging at the begining....

    problem is how that docs object available to retrieve.php file untill the user quits the project????
     
    Harish kumara, May 18, 2009 IP
  4. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #4
    store that object in session variable
     
    octalsystems, May 18, 2009 IP