Home > Backend Development > PHP Tutorial > Problems with const variables and connectors

Problems with const variables and connectors

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-06 13:52:27
Original
1658 people have browsed it

When a variable defined by the const keyword is concatenated with a string and assigned to another const variable,

<code>报syntax error, unexpected '.', expecting ',' or ';'
</code>
Copy after login
Copy after login

The code is as follows

<code>const a = '你好';
const b = a.'certs/';//直接报错</code>
Copy after login
Copy after login

Can you please help me

Reply content:

When a variable defined by the const keyword is concatenated with a string and assigned to another const variable,

<code>报syntax error, unexpected '.', expecting ',' or ';'
</code>
Copy after login
Copy after login

The code is as follows

<code>const a = '你好';
const b = a.'certs/';//直接报错</code>
Copy after login
Copy after login

Can you please help me

Nothing to help, the grammar doesn’t allow you to write like this.
Const definitions cannot use operators, variables and the like.
Besides what a is, at least it should be const b = self::a . 'certs/', although it is still illegal.

You lack context. You can only use it in a class. For external PHP constants, use define
PHP constants

Related labels:
php
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 Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template