在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>
答案 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>';
该函数将返回字符串,它将像变量一样连接。