T
T
Torento203452021-06-10 19:23:03
PHP
Torento20345, 2021-06-10 19:23:03

How to insert a class variable into a string without dots?

There is a class

class Names {
public static $egor = "Egor Ignatich";
}

There is a line
$mail = "Welcome to php, Mr ...";
How to substitute instead of three points Names::$egor?
I tried just to insert it through {}, but it doesn't work.
Dots are also not an option, there may be an insert in the center and not one.
Or how can it be done better?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2021-06-10
@Torento20345

$mail = "Welcome to php, Mr %s";
echo sprintf($mail, Names::$egor);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question