php heredoc 变量,在PHP中使用heredoc中的变量(SQL实践)

我是PHP / SQL的新手,我正在尝试在heredoc中使用一个变量,因为我需要很多文本。我只包括第一句话,足以显示问题)。

我的问题是,在heredoc中,变量(见下文:$ data [‘game_name]和$ data [‘game_owner’])不被识别为一个变量,而是作为纯文本。我该如何解决?

try

{

//i am connecting the the database base mysql 'test'

$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;

$bdd = new PDO('mysql:host=localhost;dbname=test', 'root', '', $pdo_options);

//the i read the data in the databse 'video_dame'

$response = $bdd->query('SELECT * FROM video_game');

//pour qu'elle soit visible à l'écran, on affiche chaque entrée une à une

while ($data= $response->fetch())

{

echo <<

Game: $data['game_name]

the owner of the game is $data['game_owner']

EX;

}

//i end the sql request

$response->closeCursor();

}

catch (Exception $e)

{

die('Error: '.$e->getMessage());

}

?>

任何帮助将不胜感激。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值