在html标签中使用PHP变量 [英] using PHP variables in html tag

查看:81
本文介绍了在html标签中使用PHP变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从PHP代码中获得一个变量,这是一个网页链接,并希望在html标记中使用它。
例如:

I get a variable from PHP code which is a webpage link, and want to use that in html tag. For example:

<?php 
  $link;

  ...
  $link = $client->api();
?>
 <a href= "<?php $link ?>" > LINK </a>

如何获得html标签中的链接值?
谢谢!

How can I get the link value in html tag? Thank you!

推荐答案

如果你有html文件,那么先改变扩展名.php代替.html

if you have html file then fist change the extention .php in place of .html

例如。你有test.html,然后将其更改为test.php

eg. you have test.html then change that to test.php

之后,您使用相同的代码作为

after that you use the same code as

<?php $link='http://stackoverflow.com' ?>

<a href= "<?php echo $link; ?>" > LINK </a>

希望这能帮助您

这篇关于在html标签中使用PHP变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆