Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当herdeoc';MySQL文本类型中的s字符串_Php_Mysql_Heredoc - Fatal编程技术网

Php 当herdeoc';MySQL文本类型中的s字符串

Php 当herdeoc';MySQL文本类型中的s字符串,php,mysql,heredoc,Php,Mysql,Heredoc,我将herdoc存储在MySQL文本类型中,如下所示 Hi, $candidate. This is $interviewer speaking. 我想像下面这样使用herdoc dynamicali。 (“$mailTemplate->body”是上面MySQL文本类型中的字符串。) 有什么想法吗?还是不可能 谢谢。不,你不能这样做body中的code>$…被视为文本 但是你可以用这个 $text = "Hello %s this is a %s."; $valueA

我将herdoc存储在MySQL文本类型中,如下所示

Hi, $candidate.
This is $interviewer speaking.
我想像下面这样使用herdoc dynamicali。 (“$mailTemplate->body”是上面MySQL文本类型中的字符串。)

有什么想法吗?还是不可能


谢谢。

不,你不能这样做<您的
$mailTemplate->body
中的code>$…被视为文本

但是你可以用这个

$text = "Hello %s this is a %s.";

$valueA = 'World';
$valueB = 'test';

echo sprintf(
    $text,
    $valueA,
    $valueB
);
工作

输出
将字符串中的所有变量替换为
%s
,并在
sprintf

中提供参数值。不,不能这样做<您的
$mailTemplate->body
中的code>$…被视为文本

但是你可以用这个

$text = "Hello %s this is a %s.";

$valueA = 'World';
$valueB = 'test';

echo sprintf(
    $text,
    $valueA,
    $valueB
);
工作

输出
将字符串中的所有变量替换为
%s
,并在
sprintf

中作为参数提供值,这样可以节省我的时间。谢谢你的回答和支持!不客气:)如果你说到点子上,尽管说。你节省了我的时间。谢谢你的回答和支持!不客气:)如果有问题,请随意回答。
$text = "Hello %s this is a %s.";

$valueA = 'World';
$valueB = 'test';

echo sprintf(
    $text,
    $valueA,
    $valueB
);
Hello World this is a test.