Predefinition in PHP refers to the built-in constants, variables and functions that are considered globally available. These contents do not need to be specially introduced or declared and exist in the PHP language itself.
Operating system for this tutorial: Windows 10 system, php8.1.3 version, Dell G3 computer.
Predefined in PHP refers to the built-in constants, variables and functions that are considered globally available
1. Predefined constants
Predefined constants are constants defined by PHP itself. Developers can use them directly without declaring or defining them themselves:
PHP_VERSION:当前 PHP 版本号 PHP_OS:运行 PHP 的操作系统 PHP_EOL:当前操作系统的行尾标识符TRUE、FALSE、NULL:分别表示真、假和空值
2. Predefined variables
Predefined variables are also usually called super global variables. They have global scope and developers can access them from any function or class method. The following are some common predefined variables:
$_SERVER:包含一系列服务器环境变量和请求信息 $_GET:包含通过 GET 方法提交过来的参数 $_POST:包含通过 POST 方法提交过来的参数 $_COOKIE:包含存储在客户端的 Cookie 数据 $_SESSION:包含跨页面会话期间存储的数据 $_FILES:包含上传文件的相关信息 $_REQUEST:包含所有 HTTP 请求数据,包括 GET、POST 和 COOKIE 数据
3. Predefined functions
Predefined functions are built-in functions provided by the PHP language and can be used directly in scripts , without prior declaration or import. The following are some common booking functions:
print()、echo():分别用于输出字符串到浏览器 count():用于获取数组元素的个数 isset()、empty():分别用于判断变量是否
The above is the detailed content of What does predefinition mean in php. For more information, please follow other related articles on the PHP Chinese website!