在回声PHP中使用回声

时间:2013-11-10 18:27:49

标签: php string echo

在PHP中是否可以在已包含文本的echo语句中使用site_url?例如我可以改变:

$data['following'] = 'You are not following ' . $name . ' <a href="http://raptor.kent.ac.uk/proj/co539/microblog/jlo21/index.php/user/follow/' . $name . ' ">Follow this user</a>';

$data['following'] = 'You are not following ' . $name . ' <a href="<?php echo site_url("user/follow"); ?>">Follow this user</a>

3 个答案:

答案 0 :(得分:1)

不,但为什么不连接返回值而不是尝试echo呢?

$data['following'] = 'You are not following ' . $name . ' <a href="' . site_url("user/follow") . '">Follow this user</a>

答案 1 :(得分:0)

$data['following'] = 'You are not following ' . $name . ' <a href="' . site_url("user/follow") . '">Follow this user</a>;

答案 2 :(得分:0)

您可以在字符串连接中使用函数调用:

$data['following'] = 'You are not following ' . $name . ' <a href="'. site_url("user/follow") . '">Follow this user</a>';

该函数将返回字符串,它将像变量一样连接。