PHP 文件中的超链接
Hyperlink in PHP file
HTML 文件中的 link:
<a href="<?= Config::get('URL') . 'profile/showProfile/' . $user->user_id; ?>">Profile</a>
有效!
PHP 文件中的相同 link:
echo "<a href='"<?= Config::get('URL') . 'profile/showProfile/' . $user->user_id; ?>"'>Profile</a>";
无效!
我做错了什么?
当您已经作为 PHP 代码执行时,您不需要包含 <?=
。
echo "<a href='" . Config::get('URL') . 'profile/showProfile/' . $user->user_id . "'>Profile</a>";
试试这个
$url = Config::get('URL');
echo "<a href='".$url. 'profile/showProfile/'.$user->user_id."'>Profile</a>";
HTML 文件中的 link:
<a href="<?= Config::get('URL') . 'profile/showProfile/' . $user->user_id; ?>">Profile</a>
有效!
PHP 文件中的相同 link:
echo "<a href='"<?= Config::get('URL') . 'profile/showProfile/' . $user->user_id; ?>"'>Profile</a>";
无效!
我做错了什么?
当您已经作为 PHP 代码执行时,您不需要包含 <?=
。
echo "<a href='" . Config::get('URL') . 'profile/showProfile/' . $user->user_id . "'>Profile</a>";
试试这个
$url = Config::get('URL');
echo "<a href='".$url. 'profile/showProfile/'.$user->user_id."'>Profile</a>";