Can php delete constants?

coldplay.xixi
Release: 2023-03-03 19:34:01
Original
3490 people have browsed it

PHP cannot delete constants, reasons: 1. When assigning a constant to a variable, it actually assigns a value, but it is still a constant; 2. Once a constant is defined, it cannot be replaced

Can php delete constants?

#php cannot delete constants, only variables.

Assigning a constant to a variable is actually assigning a value, but it is still a constant.

All constants cannot be deleted.

And the constants you define cannot be changed, they are fixed.

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

Proof 1: The constant cannot be deleted

Copy after login

Execution result: Syntax Error

Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in C:\wamp\www\Untitled-1.php on line 11
Copy after login

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

Copy after login

Result: (Error message: Note that abc is already a constant.)

abc Notice: Constant abc already defined in C:\wamp\www\Untitled-1.php on line 12 abc
Copy after login
';//空白 $abc='我是变量'; ecoh $abc; ?>
Copy after login

Use directly $ defines all variables.

Relevant learning recommendations:php graphic tutorial

The above is the detailed content of Can php delete constants?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!