Problems with const variables and connectors

WBOY
Release: 2016-07-06 13:52:27
Original
1605 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
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template