在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>发布于 2013-11-11 02:30:00
没有,但是为什么不直接连接返回值而不是尝试echo它呢?
$data['following'] = 'You are not following ' . $name . ' <a href="' . site_url("user/follow") . '">Follow this user</a>发布于 2013-11-11 02:29:28
$data['following'] = 'You are not following ' . $name . ' <a href="' . site_url("user/follow") . '">Follow this user</a>;发布于 2013-11-11 02:32:03
您可以在字符串连接中使用函数调用:
$data['following'] = 'You are not following ' . $name . ' <a href="'. site_url("user/follow") . '">Follow this user</a>';该函数将返回字符串,并且它将像变量一样连接在一起。
https://stackoverflow.com/questions/19893380
复制相似问题