Skip to content

Using single quotes around strings that don't require expansion/evaluationΒ #63

@Mikecom32

Description

@Mikecom32

I searched and didn't see a previous issue for this. Do you think we should recommend using single quotes around any string that doesn't require some type of evaluation?

I'd propose that if a string is just a string, it should be surrounded by single quotes:

$testVariable1 = 'This is a plain string.'
$testVariable2 = 'This is a string containing a $variable I don't want evaluated'
$testVariable3 = "This is a string containing a $variable I want evaluated"

as opposed to:

$testVariable1 = "This is a plain string."
$testVariable2 = 'This is a string containing a $variable I don't want evaluated'
$testVariable3 = "This is a string containing a $variable I want evaluated"

I think this improves readability and is more consistent. Also, while the difference is very minimal, single quoted strings generally perform faster than double quoted strings when there is no expansion/evaluation.

A bit more info:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions