Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3696416
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:44:11+00:00 2026-05-19T04:44:11+00:00

I’m still fairly new to PHP and so I’m attempting to understand scope concepts

  • 0

I’m still fairly new to PHP and so I’m attempting to understand scope concepts within PHP web applications.

In the Java world a Java web app – using Java Server Pages (JSP) and upward – will allow a Java Bean to have the following levels of scope:

  • Page
  • Request
  • Session
  • Application

Attempting to map these to PHP’s scoping capabilities:

  • Page: not really but objects that are local to a call are considered ‘gone’ after the function call is made so it’s sort of like a page scope
  • Request: made by using the “$_REQUEST super global (not sure where this goes … Cookies? Hidden fields? URL parameters?)
  • Session: using PHP’s $_SESSION super global (where some of the documentation and forum feedback states that this is not a great place to put sensitive information for security reasons)
  • Application: using PHP’s APC (a Stack Overflow link)

Am I totally out to lunch or are these reasonably similar? I know that one major difference is PHP’s [“Shared Nothing”][5] architecture as compared to Java’s which is to allow for sharing.

Any advice/guidance/sobering corrections most welcome.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:44:12+00:00Added an answer on May 19, 2026 at 4:44 am

    You’re on the right track. PHP is indeed Share-Nothing.

    In a web context, a php application runs, in it’s entirety, once for each HTTP request. This means for every HTTP request the interpreter reads, parses and executes the script (this is simplified – using an opcode cache like APC removes the reading/parsing overhead).

    PHP feeds input to the script in the form of superglobals, such as $_REQUEST and $_SESSION. Superglobals are different from regular global variables in that they’re automatically available in every scope, so there’s no need to use the global keyword.

    Any data that persist between requests need to be stored externally. To share data across requests to maintain state for a user, you typically use $_SESSION, which by default is serialized and written to files on disk (but can be configured to use a memory cache or database). Data that are to be shared between sessions (which I suppose is similar to the Application scope in the JSP world) need to be stashed somewhere external. You can use a memory cache like APC or memcache, or write flat files to disk, or stick stuff in a database, or use any other scheme you can come up with. At the end of the day, there’s nothing built-in.

    Aside from superglobals, variable scope is fairly boring. By default, variables live in the scope in which they’re created.

    To reference a global variable in a non-global scope (ie: inside a function), you need to import the symbol into the local scope using the global keyword. PHP works this way to make it harder to accidentally clobber global variables.

    This stuff, and more, is covered pretty well in the manual.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.