Include constant in string without concatenating
In PHP, you can include a constant in a string without concatenating it by using double quotes (") instead of single quotes (') to define the string.
In PHP, you can include a constant in a string without concatenating it by using double quotes (") instead of single quotes (') to define the string.
For example, if you have a constant defined as:
Example of defining constants in PHP
<?php
define("MY_CONSTANT", "Hello World");
<div class="alert alert-info flex not-prose">![]()
<span class="hidden md:block">Watch a video course</span>Learn object oriented PHP</div>
You can include it in a string as follows:
Example of including constant in string without concatenating in PHP
<?php
define("MY_CONSTANT", "Hello World");
echo sprintf("This is my constant: %s", MY_CONSTANT);