PHP: 在 <a> link 中编辑 href

PHP: Edit href in <a> link

我想将 URL 编辑为特定的 URL,因为我在 WordPress 和 cPanel 的 phpMyAdmin 中都找不到用户元数据。

我想改变这个:

if(get_user_meta( $user_id, 'googleplus', $single) !=""){
  echo "<br/><a class='author-link g' title='Follow on Google+' href=".get_user_meta( $user_id, googleplus', $single )." target='_blank'>Google+</a>";
  }

收件人:

if(get_user_meta( $user_id, 'googleplus', $single) !=""){
  echo "<br/><a class='author-link g' title='Follow on Google+' href="https://example.com" target='_blank'>Google+</a>";
  }

错误是:

syntax error, unexpected 'https' (T_STRING), expecting ',' or ';'

我试过:

href="<?php echo "http://www.example.com"; ?>"
href="https:\/\/www.example.com"
href="https://www.example.com"

感谢任何建议,因为我对 PHP 的知识为零。

改变

 echo "<br/><a class='author-link g' title='Follow on Google+' href="https://example.com" target='_blank'>Google+</a>";

 echo '<br/><a class="author-link g" title="Follow on Google+" href="https://example.com" target="_blank">Google+</a>';

您使用时出错single quoted and double quoted 在你的代码中 将 "example.com" 更改为 'example.com' 或者像这样使用它 \"example.com\" 来转义双引号

最终权限代码为

if(get_user_meta( $user_id, 'googleplus', $single) !=""){
  echo "<br/><a class='author-link g' title='Follow on Google+' href='https://example.com' target='_blank'>Google+</a>";
  }