Can php constants be removed? Can a constant value defined in PHP be changed again?

Updated on technology 2024-03-20
16 answers
  1. Anonymous users2024-02-07

    The session is divided into two parts, the session space is stored on the server side, and the ID of the open space is stored in the client's cookie.

    Given that this confusion is no longer changeable, it is difficult to come up with a uniform standard for defining sessions. And when we read session-related materials, we can only infer understanding by context. But we can understand it this way:

    For example, when we call **, from the moment of dialing to the time of hanging up**, because ** has always maintained the state of being connected, this state of connection is called session. It is a public variable that has always existed in the process of interaction between the visitor and the whole **, and when the client does not support cookies, in order to ensure the accuracy and security of the data, the session variable is used. Visitors who visit ** are assigned a unique identifier, the so-called session ID.

    It is either a cookie placed on the client side or passed via a URL.

    The invention of Session fills the limitations of the HTTP protocol: the HTTP protocol is considered a stateless protocol that cannot know the user's browsing status, and when it completes its response on the server, the server loses contact with the browser. This is in line with the original purpose of the http protocol, the client only needs to simply request some files from the server, neither the client nor the server needs to record each other's past behavior, each request is independent, like the relationship between a customer and a vending machine or a regular (non-membership) hypermarket.

  2. Anonymous users2024-02-06

    No, you can only delete variables.

    Upstairs are all variables.

    When you assign a constant to a variable, you actually assign a value to it, but you are still a variable.

    All constants cannot be deleted.

    And the constants you define yourself can't be changed, and you're condemned to death.

    So the 1st and 2nd floors are all.

    Evidence: define defines a constant define(constant name, value);

    Evidence 1: Constants cannot be deleted.

    Result: Syntax error.

    Evidence 2: Once a constant is defined, it cannot be replaced.

    Result: (Error meaning: Note, abc is already a constant.) The direct on the 2nd floor of the abc is a variable because:

    Variables are defined directly by $. 、

    If what I'm saying isn't accurate, you can check out the encyclopedia:

    Refers to the amount whose value cannot be changed during the operation of the program. Unlike variables, constants don't have names, and since constants are also stored, they have an address.

    That is, an immutable quantity, and it lasts for a long time. Otherwise, what should be done with constants?

  3. Anonymous users2024-02-05

    Yes, for example, if I want to delete $a, I can unset($a), and what I said upstairs is also a good method!

  4. Anonymous users2024-02-04

    If you want to delete constants, you can remove them by reassigning them.

  5. Anonymous users2024-02-03

    No, once a constant is assigned, it will not be modified.

  6. Anonymous users2024-02-02

    Hello, there is nothing that is not possible, just a shortcut (io), which means that you can modify the content of the php constant text you imported, php can modify the content of the text file, you can understand that the php file is a text file.

  7. Anonymous users2024-02-01

    No, so many constants are defined to determine whether they have been defined once, e.g.

    defined("changliang") or define("changliang", 1);

  8. Anonymous users2024-01-31

    A script needs to be executed for a few days, so it's easy to go wrong.。。 You can improve it in other ways1Scheduled Task Scheduled Request 2

  9. Anonymous users2024-01-30

    A constant is an identifier (name) for a single value. You can't change this value in the script.

    Valid constant names start with a character or underscore (the constant name is not preceded by a $ sign).

    Note: Unlike variables, constants are automatically global throughout the script.

  10. Anonymous users2024-01-29

    As the name suggests, constants cannot be modified, and they should be defined by assigning a value and not adding $. There are two ways to define it.

    tax_rate",1);

    tax_rate=1 ;The second option is only applicable to the above versions.

  11. Anonymous users2024-01-28

    Occupy is definitely occupied. It can be ignored though. Because the general server has ZendOptimizer, the garbage processing draft pretend macro mechanism is very strong, when the programmer programs the key book, in the case of stable operation and stable CPU occupancy, the problem of constant memory occupation can be ignored.

  12. Anonymous users2024-01-27

    Let's put it this way, if the memory occupied is not negligible, such as 1 constant 1m memory, then who still uses constants?

  13. Anonymous users2024-01-26

    It will definitely steal the old memory! Don't take up memory that put in **!? Occupies less memory than other types of variables!

    Because a constant is just a string! Variables can be of many types, and the structure is more complex! You can test it out with memory get usage()!

    View the original post

  14. Anonymous users2024-01-25

    Generally speaking, a static attribute refers to a static member property of a class, which is decorated with static, although it is nominally static, but its value can still be changed by the member method in the class. Member methods in the class access static properties via self:: instead of via $this->

    Static constants, generally decorated with const, can be defined without writing the $ symbol, and the method in the class cannot change its value, and the const keyword cannot be used on a relatively low PHP version (less than or equal to.

  15. Anonymous users2024-01-24

    Static properties of the class. It will be initialized when the class file is loaded.

    Attribute values can be changed.

    Constant. Once defined. You can't change the value.

    That's probably the biggest difference.

    In addition, constants can only be simple data types (e.g., int, string, boolean, float, double), static properties of classes, and can be any variable type supported by PHP (but initialized). can only be a simple data type, array).

  16. Anonymous users2024-01-23

    Make it possible for the same function to use the same shared variable when called multiple times. It's static variables.

Related questions
11 answers2024-03-20

Valid character constants are:

a.'084' is not legal, there is no 8 in octal. >>>More

6 answers2024-03-20

Amount of energy. Volume is volume.

Energy is the momentum of funds. >>>More

12 answers2024-03-20

Variables can be included in double quotes, where $str reads look at the sea"$str";It will recognize that $str is a variable and explain the contents of the variable to get it"look at the sea", and single quotes'$str'It is to output the string $str, depending on the situation. Sometimes you need to make up a SQL statement with some variables, and double quotation marks are useful. >>>More

4 answers2024-03-20

1.Need a field trip to choose the learning style that suits you; >>>More

14 answers2024-03-20

This means to judge that the variable $entry is not equal to. And not equally. and the following is dir($dir.$entry) Yes. >>>More