【问题标题】:I can't access internet pages when i use xampp localhost使用 xampp localhost 时无法访问互联网页面
【发布时间】:2017-01-25 13:48:08
【问题描述】:

我在 osX 上为我的 php 文件使用 xampp,但是当我使用 localhost 时,我可以正确运行 php 行,但我无法打开带有 <a> 标签的 google 之类的页面! 当我使用“localhost/test.php”运行我的程序时:

<html>
<?php echo "<a href='google.com'> google </a>" ?>
</html>

当我点击谷歌...这个链接打开:localhost/google.com 当然不存在!我尝试使用“http://google.com”或“../google.com”,但没有成功……我该怎么办?

【问题讨论】:

  • 需要阅读一下相对路径和绝对路径的工作原理。问题与运行 localhost 无关......这是浏览器如何解释这些 href 值
  • 如果我尝试在同一设置中使用“http​:​/​/google.com”(在 localhost 上运行的 php 程序),它会按预期工作,所以我不知道为什么一个不会为你工作。或者为什么答案坚持包括 s 和 www。

标签: php html macos xampp


【解决方案1】:

尝试使用正确的地址。

喜欢https://www.google.com/

您可以在&lt;a href="..."&gt; 上添加标签target="_blank"

完整示例:

&lt;a href="https://www.google.com/" target="_blank"&gt;Google&lt;/a&gt;

Here 是可能的目标。

希望这会有所帮助。

【讨论】:

  • @saee 记得接受答案并随时点赞。
【解决方案2】:
<a href="https://www.google.com" target=_blank>Google</a>

试试看

【讨论】:

    猜你喜欢
    • 2011-07-03
    • 2015-11-10
    • 1970-01-01
    • 1970-01-01
    • 2018-01-17
    • 2018-06-02
    • 2016-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多