Search⌘ K

Backticks and Laravel String Helpers

Learn about the details of backticks and template strings with the help of examples.

Backticks

PHP developers commonly move back and forth between front-end languages, such as JavaScript, and our backend languages. When working in languages like JavaScript, it is common to construct template strings using the backtick character (`):

`Hello, ${name}.`

It is imperative to note that to accomplish the same thing in PHP, we should use the heredoc syntax or double-quoted strings:

PHP
<?php
$string = <<<STRING
Hello, {$name}.
STRING;
echo $string = "Hello, {$name}.";

Implementing backticks as shell commands

The ...