---
title: "Lexical Rules"
url: https://docs.zeroc.com/ice/3.8/slice/lexical-rules
language: php
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Lexical Rules

Programming language: PHP. Other languages: [C++](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/matlab.md), [Python](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/ruby.md), [Swift](https://docs.zeroc.com/ice/3.8/slice/lexical-rules/swift.md).

## Comments

Slice supports block comments, delimited by `/*` and `*/`, and line comments, which start with `//` and extend to the end of the line:

```slice
/*
 * Block comment.
 */

// Line comment.
```

Slice also supports doc comments, which document the definition that follows them: line comments that start with `///` and block comments that start with `/**`. See [Comment Syntax](https://docs.zeroc.com/ice/3.8/slice/documenting-slice-definitions/comment-syntax.md).

## Keywords

Slice uses a number of [keywords](https://docs.zeroc.com/ice/3.8/slice/slice-keywords.md), which must be spelled in lowercase, such as `class` and `dictionary`. The keywords `Object` and `Value` are the exceptions: they must be capitalized as shown.

## Identifiers

An identifier begins with an ASCII letter, followed by any number of ASCII letters, digits, and underscores. An identifier cannot begin or end with an underscore, or contain two consecutive underscores: `get_account_name` is legal, but `_account`, `account_`, and `get__account` are not. Non-ASCII letters, such as Å, cannot appear in an identifier.

An identifier cannot end with `Helper`, `Holder`, `Prx`, or `Ptr`: the Slice compilers reserve these suffixes.

### Case Sensitivity

Identifiers that differ only in capitalization are the same identifier: you cannot declare both `TimeOfDay` and `TIMEOFDAY` in the same scope. After you declare an identifier, you must refer to it with the same capitalization; otherwise, the compiler rejects the reference.

### Escaped Identifiers

You can use a Slice keyword as an identifier by prefixing it with a backslash:

```slice
struct Value     // Error!
{
    // ...
}

struct \Value    // OK
{
    // ...
}
```

The backslash lets an existing definition keep a name that a later version of Slice makes a keyword. In new definitions, avoid keywords as identifiers. A backslash before an identifier that is not a keyword has no effect.

### Language Mapping

A Slice identifier maps to an identical PHP identifier, or a PHP identifier derived from this Slice identifier. For example, the Slice-to-PHP compiler generates the PHP class `GreeterPrxHelper` for Slice interface `Greeter`.

A Slice identifier that is a PHP keyword keeps its name in the generated PHP code, which is then invalid when this identifier names a PHP class, such as the class of a Slice structure. PHP keywords are case-insensitive, so the Slice structure `List` conflicts with the PHP keyword `list`. Give this identifier a PHP name of your choice with the `php:identifier` metadata directive:

```slice
["php:identifier:ItemList"]
struct List
{
    string name;
}
```

In the generated PHP code, the class for `List` is named `ItemList`.

## See Also

- [Slice Keywords](https://docs.zeroc.com/ice/3.8/slice/slice-keywords.md)
- [Comment Syntax](https://docs.zeroc.com/ice/3.8/slice/documenting-slice-definitions/comment-syntax.md)
- [Slice Metadata Directives](https://docs.zeroc.com/ice/3.8/slice/slice-metadata-directives/php.md)
