mrwaim
mrwaim

Reputation: 2071

String type casing in php, is it string or String?

What is the official name for the php string type?

Is it 'string' like c#, or 'String' like Java, or either?

I could not find it in http://php.net/manual/en/language.types.string.php

I want to use it to strict type my function

function getImageName() : string;

or

function getImageName() : String;

Upvotes: 6

Views: 1157

Answers (1)

Alex Shesterov
Alex Shesterov

Reputation: 27525

As PHP is a partially case sensitive language and, in particular, keywords are NOT case sensitive, the case doesn't matter for built-in type names. Both string and String will work as type declaration (aka 'type hint').

The official documentation mentions the lowercase variants, so it's probably a good idea to use lowercase keywords as code style — just like most PHP code styles use foreach and not Foreach, for example.

P.S. You can find the documentation on the PHP Function arguments page, 'Type declarations' section.

Upvotes: 10

Related Questions