How to create a link to another PHP page

I just converted some of my pages HTMLto pages PHP, and I am not familiar with PHP. On my pages HTML, considering this to be just a static web application, I can simply link to another page by playing the following anchoron the page:

<a href="go-to-this-page.html">This is a link</a>

So, after converting the pages to PHP, to make sure that I can create templates and include templates a little easier and faster, I do not know how to include these links.

For example, let's say I have two pages, index.phpand page2.php. How to create a binding to this page?

<a href="??????">This is a link</a>

Thanks for any help!

+4
source share
6 answers

Use it as

<a href="index.php">Index Page</a>
<a href="page2.php">Page 2</a>
+6
source

Simplest:

<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 extract the value placed in page2.php, this code:

<?php
$val = $_GET["val"];
?>

Now the var variable has a value of "1".

+3
source

Just try it like this:

HTML in PHP:

$link_address1 = 'index.php';
echo "<a href='".$link_address1."'>Index Page</a>";

$link_address2 = 'page2.php';
echo "<a href='".$link_address2."'>Page 2</a>";

The 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>";
+1
source

You can also use this

<a href="<?php echo 'index.php'; ?>">Index Page</a>
<a href="<?php echo 'page2.php'; ?>">Page 2</a>
+1
source
echo "<a href='index.php'>Index Page</a>";

if you want to use the html tag, e.g. anchor tag, you must enter echo

+1
source

Html tag

Link in html

 <a href="index1.php">page1</a>
 <a href="page2.php">page2</a>

Html in php

echo ' <a href="index1.php">page1</a>';
echo '<a href="page2.php">page2</a>';
+1
source

All Articles