Having problems displaying variables in php page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bluefire
    New Member
    • May 2007
    • 2

    Having problems displaying variables in php page

    when I echo "$variable<br>" ;

    it shows the link perfect....

    but when i create <a href="$variable ">button</a>

    i get a solid white page?

    How should I be doing this? All i want is to turn my variable into a clickable link!
  • bluefire
    New Member
    • May 2007
    • 2

    #2
    figured it out incase anyone else needs this

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

    Comment

    • Motoma
      Recognized Expert Specialist
      • Jan 2007
      • 3236

      #3
      Thanks for posting the answer back when you discovered it. In PHP there are a number of different ways to do this:
      [PHP]
      <a href="<?=$varia ble?>">LINK HERE</a>
      [/PHP]

      [PHP]
      <?php
      echo "<a href=""$variabl e"">LINK HERE</a>";
      ?>
      [/PHP]

      [PHP]
      <?php
      echo '<a href="'.$variab le.'">LINK HERE</a>';
      ?>
      [/PHP]

      What it really boils down to is that you were not calling $variable in PHP's scope (i.e. inside <?php ?> brackets).

      Hope this helps.

      Originally posted by bluefire
      figured it out incase anyone else needs this

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

      Comment

      Working...