如何创建到另一个 PHP 页面的链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29387236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a link to another PHP page
提问by germainelol
I just converted some of my HTML
pages to PHP
pages, and I'm not that familiar with PHP
. In my HTML
pages, assuming it's just a static web app, I can link to another page quite simply by playing the following anchor
on the page:
我只是将我的一些HTML
页面转换为PHP
页面,我对PHP
. 在我的HTML
页面中,假设它只是一个静态 Web 应用程序,我可以通过anchor
在页面上播放以下内容来非常简单地链接到另一个页面:
<a href="go-to-this-page.html">This is a link</a>
<a href="go-to-this-page.html">This is a link</a>
So, after converting the pages to PHP
in order to make sure that I can template and include templates a bit easier and faster, I don't know how to include these links.
因此,在将页面转换为 之后PHP
,为了确保我可以更轻松、更快速地模板和包含模板,我不知道如何包含这些链接。
For example, say I have two pages, index.php
and page2.php
. How would I create an anchor link to this page?
例如,假设我有两页,index.php
并且page2.php
. 我将如何创建指向此页面的锚链接?
<a href="??????">This is a link</a>
<a href="??????">This is a link</a>
Thanks for any help!
谢谢你的帮助!
回答by Rex Rex
Use like this
像这样使用
<a href="index.php">Index Page</a>
<a href="page2.php">Page 2</a>
回答by Gianluca Pin
Easiest:
最简单:
<a href="page2.php">Link</a>
And if you need to pass a value:
如果您需要传递一个值:
<a href="page2.php?val=1">Link that pass the value 1</a>
To retrive the value put in page2.php this code:
要检索放置在 page2.php 中的值,请使用以下代码:
<?php
$val = $_GET["val"];
?>
Now the variable $val
has the value 1
.
现在变量$val
的值为1
。
回答by Priyank
Just try like this:
试试这样:
HTML in PHP :
PHP 中的 HTML :
$link_address1 = 'index.php';
echo "<a href='".$link_address1."'>Index Page</a>";
$link_address2 = 'page2.php';
echo "<a href='".$link_address2."'>Page 2</a>";
Easiest way
最简单的方法
$link_address1 = 'index.php';
echo "<a href='$link_address1'>Index Page</a>";
$link_address2 = 'page2.php';
echo "<a href='$link_address2'>Page 2</a>";
回答by Waqas Khan
You can also used like this
你也可以这样使用
<a href="<?php echo 'index.php'; ?>">Index Page</a>
<a href="<?php echo 'page2.php'; ?>">Page 2</a>
回答by Navin Bhandari
echo "<a href='index.php'>Index Page</a>";
if you wanna use html tag like anchor tag you have to put in echo
如果你想使用像锚标签这样的 html 标签,你必须输入 echo
回答by user3386779
Html a tag
HTML 标签
Link in html
html中的链接
<a href="index1.php">page1</a>
<a href="page2.php">page2</a>
Html in php
php中的html
echo ' <a href="index1.php">page1</a>';
echo '<a href="page2.php">page2</a>';