国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Constants for beginners to PHP

One:What is a constant

After a constant value is defined, it cannot be changed anywhere else in the script

A constant is an identifier of a simple value , a constant consists of English letters, underscores, and numbers, but numbers cannot appear as the first letter. (Constant names do not need to be added with the $ modifier)

Note: Constants can be used throughout the script

2:Set PHP constants

Use define() function

Syntax format:

bool define ( string $name , mixed $value [, bool $case_insensitive = false ] )

The define function has 3 parameters

1.name: required parameter, constant name, i.e. identifier

2.value: required parameter, constant value

3 .case_insensitive optional parameter, if set to TRUE, this constant is case-insensitive. The default is case-sensitive

<?php
	header("Content-type: text/html; charset=utf-8"); 
	// 區(qū)分大小寫的常量名
	define("GREETING", "歡迎訪問  taobao.com");
	echo GREETING;    // 輸出 "歡迎訪問 taobao.com"
	echo '<br>';
	echo greeting;   // 輸出 "greeting"
?>

Note: This is case-sensitive, so an error will be reported


Let’s write a case-insensitive one

<?php
	header("Content-type: text/html; charset=utf-8"); 
	// 不區(qū)分大小寫的常量名
	define("GREETING", "歡迎訪問 taobao.com", true);
	echo greeting;  // 輸出 "歡迎訪問taobao.com"
?>

Note: This will output "Welcome to taobao.com" without reporting an error

Constants can be used outside without quotation marks only Scalars can be used

<?php
	header("Content-type: text/html; charset=utf-8"); 
	// 不區(qū)分大小寫的常量名
	define("GREETING",array(1,2,1,1));
	echo greeting;  // 輸出 "歡迎訪問淘寶"
?>

In addition, the system has also prepared some built-in constants for us as shown in the figure below

5.png

Continuing Learning
||
<?php header("Content-type: text/html; charset=utf-8"); // 區(qū)分大小寫的常量名 define("GREETING", "歡迎訪問 taobao.com"); echo GREETING; // 輸出 "歡迎訪問 " echo '<br>'; echo greeting; // 輸出 "greeting" ?>
submitReset Code