php 创建软链接_如何在PHP中创建链接

php 创建软链接

Websites are filled with links. You're probably already aware of how to create a link in HTML. If you've added PHP to your web server to be able to enhance your site's capabilities, you may be surprised to learn that you create a link in PHP the same as you do in HTML. You have a few options, though. Depending on where in your file the link is, you might present the link HTML in a slightly different way.

网站上充斥着链接。 您可能已经知道如何在HTML中创建链接。 如果您已将PHP添加到Web服务器中以增强站点的功能,则可能会惊讶地发现,用PHP创建链接的方式与使用HTML创建链接的方式相同。 不过,您还有一些选择。 根据链接在文件中的位置,您可能会以略有不同的方式显示链接HTML。

You can switch back and forth between PHP and HTML in the same document, and you can use the same software—any plain text editor will do—to write PHP as to write HTML.

您可以在同一文档中PHP和HTML之间来回切换,并且可以使用相同的软件(任何纯文本编辑器都可以这样做)来编写PHP和编写HTML。

如何向PHP文档添加链接 ( How to Add Links to PHP Documents )

If you are making a link in a PHP document that is outside of the PHP brackets, you just use HTML as usual. Here is an example:

如果要在PHP括号之外PHP文档中建立链接,则只需照常使用HTML。 这是一个例子:


<a href="https://twitter.com/angela_bradley">My Twitter</a>
<?php
----- My PHP Code----
?>

If the link needs to be inside the PHP, you have two options. One option is to end the PHP, enter the link in HTML, and then reopen PHP. Here is an example:

如果链接需要在PHP内,则有两个选择。 一种选择是结束PHP,输入HTML链接,然后重新打开PHP。 这是一个例子:


<?php
----- My PHP Code----
?>
<a href="https://twitter.com/angela_bradley">My Twitter</a>
<?php
----- My PHP Code----
?>

The other option is to print or echo the HTML code inside the PHP. Here is an example:

另一个选择是在PHP中打印或回显HTML代码。 这是一个例子:


<?php
Echo "<a href=https://twitter.com/angela_bradley>My Twitter</a>"
?>

Another thing you can do is create a link from a variable. Let's say that the variable $url holds the URL for a website that someone has submitted or that you have pulled from a database. You can use the variable in your HTML.

您可以做的另一件事是从变量创建链接。 假设变量$ url包含有人提交或您从数据库中提取的网站的URL。 您可以在HTML中使用该变量。


<a href="https://twitter.com/angela_bradley">My Twitter</a>
<?php
Echo "<a href=$url>$site_title</a>"
?>

对于初级PHP程序员 ( For Beginning PHP Programmers )

If you are new to PHP, remember you begin and end a section of PHP code using <?php and ?> respectively. This code lets the server know that what is included is PHP code. Try a PHP beginner's tutorial to get your feet wet in the programming language. Before long, you'll be using PHP to set up a member login, redirect a visitor to another page, add a survey to your website, create a calendar, and add other interactive features to your webpages.

如果您不熟悉PHP,请记住分别使用<?php?>开头和结尾一段PHP代码。 此代码使服务器知道所包含的是PHP代码。 尝试PHP初学者的教程,以掌握编程语言。 不久之后,您将使用PHP设置成员登录名, 将访问者重定向到另一个页面,将调查添加到您的网站,创建日历以及将其他交互式功能添加到您的网页。

翻译自: https://www.thoughtco.com/create-links-in-php-2693950

php 创建软链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值