i want to echo some text with a variables in a clean way in php
One way to echo text with variables in a clean way in PHP is to use string interpolation. This involves enclosing the variable within curly braces {} within a double-quoted string. For example:
$name = "John"; echo "Hello, {$name}!";
This would output: "Hello, John!".
Another method is to concatenate the string and variable using the dot operator. For example:
$name = "John"; echo "Hello, " . $name . "!";
This would also output: "Hello, John!".
原文地址: https://www.cveoy.top/t/topic/gMWZ 著作权归作者所有。请勿转载和采集!