How to create a link to another PHP page

后端 未结 6 1236
清歌不尽
清歌不尽 2020-12-31 19:22

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\'

相关标签:
6条回答
  • 2020-12-31 19:45

    Just try 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>";
    

    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>";
    
    0 讨论(0)
  • 2020-12-31 19:49

    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:

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

    Now the variable $val has the value 1.

    0 讨论(0)
  • 2020-12-31 19:57

    You can also used like this

    <a href="<?php echo 'index.php'; ?>">Index Page</a>
    <a href="<?php echo 'page2.php'; ?>">Page 2</a>
    
    0 讨论(0)
  • 2020-12-31 19:59

    Use like this

    <a href="index.php">Index Page</a>
    <a href="page2.php">Page 2</a>
    
    0 讨论(0)
  • 2020-12-31 20:00

    Html a 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>';
    
    0 讨论(0)
  • 2020-12-31 20:02
    echo "<a href='index.php'>Index Page</a>";
    

    if you wanna use html tag like anchor tag you have to put in echo

    0 讨论(0)
提交回复
热议问题