How can you access superglobals in PHP?

  • By using the $ prefix followed by the superglobal name.
  • By declaring the variable as global within a function.
  • By using the global keyword followed by the superglobal name.
  • By using the @ symbol followed by the superglobal name.
The correct option is 1. Superglobals in PHP can be accessed by using the $ prefix followed by the superglobal name. For example, to access the $_POST superglobal, you would use the variable $_POST in your PHP code. This allows you to access the data stored in the superglobal and use it within your script. Superglobals are automatically available in all scopes without the need for any special declarations or keywords. They can be accessed directly wherever you need to use their values. Learn more: https://www.php.net/manual/en/language.variables.superglobals.php
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *