0

在 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>
4

3 回答 3

1

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

$data['following'] = 'You are not following ' . $name . ' <a href="' . site_url("user/follow") . '">Follow this user</a>
于 2013-11-10T18:30:00.093 回答
0
$data['following'] = 'You are not following ' . $name . ' <a href="' . site_url("user/follow") . '">Follow this user</a>;
于 2013-11-10T18:29:28.380 回答
0

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

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

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

于 2013-11-10T18:32:02.687 回答