Questions about the scope in PHP - from the perspective of a Java programmer

I'm still pretty new to PHP, so I'm trying to understand the concept of scopes in PHP web applications.

In the Java world, a Java web application using Java Server Pages (JSPs) and above will allow the Java Bean to have the following levels of visibility:

  • Page
  • Inquiry
  • Session
  • Application

Trying to match them with PHP definition capabilities:

  • Page: not real, but objects that are local to the call are considered “gone” after the function call is made in such a way that it looks like a page area
  • Request: made using "$ _REQUEST super global (not sure where this is happening ... Cookies? Hidden fields? URL parameters?)
  • Session: using PHP $ _SESSION super global (where some documents and forum reviews say that this is not a great place to post confidential information for security reasons).
  • Application: using PHP APC (link)

Am I completely eating dinner or are these similar? I know that one of the main differences is the PHP ["Shared Nothing"] [5] architecture compared to Java, which should provide sharing.

Any advice / recommendations / sober fixes are most welcome.

+3
source share
2 answers

You are on the right track. PHP is really Share-Nothing.

- php HTTP-. , HTTP- , script ( - , APC, /).

PHP script superglobals, $_REQUEST $_SESSION. , , global.

, , . , $_SESSION, ( ). , (, , JSP), - . , APC memcache, , . .

, . , .

(.. ), global. PHP , clobber.

.

+5

Source: https://habr.com/ru/post/1785799/


All Articles