Home  >  Article  >  Backend Development  >  PHP constants

PHP constants

巴扎黑
巴扎黑Original
2016-11-12 09:52:401250browse

Set PHP constants

To set constants, use the define() function - it takes three parameters:

The first parameter defines the name of the constant

The second parameter defines the value of the constant

The optional third This parameter specifies whether the constant name is case-sensitive. The default is false.

The following example creates a case-sensitive constant with the value "Welcome to W3School.com.cn!":

Instance

<?php
define("GREETING", "Welcome to W3School.com.cn!");
echo GREETING;
?>

Running instance

The following example creates a case-insensitive constant, The value is "Welcome to W3School.com.cn!":

Instance

<?php
define("GREETING", "Welcome to W3School.com.cn!", true);
echo greeting;
?>


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP foreach loopNext article:PHP foreach loop