WordPress.org

Ready to get started?Download WordPress

Forums

Call on a variable outside of the php function (4 posts)

  1. dml3001
    Member
    Posted 2 years ago #

    I would like to call on a variable outside of the php function.

    I want to use my url: www.mysite.com/ and add the current date to the end of it.

    I need to call on a php function to do this, therefore, I was going to do this:

    $date=<?php the_date('Y/m/d'); ?>

    Then, I want to combine my url with the date as follows:

    <a href="www.mysite.com/$date">MY TITLE</a>

    How do I go about doing this? Thanks.

  2. dml3001
    Member
    Posted 2 years ago #

    P.S. What I tried, doesn't work...

  3. mshane8
    Member
    Posted 2 years ago #

    everything has to go inside the php tags. even if the variable is created outside the function itself it cant be outside the php tags.

  4. dml3001
    Member
    Posted 2 years ago #

    How would I make an a href with the date at the end of the link then?

    <?php
    
    $url = "http://www.hiphoplot.com/";
    $date = the_date('Y/m/d/');
    echo $url . $date;
    <a href="echo $url . $date";>
    ?>
    
    	<div align="center"><font color=\"#FF00FF\"><?php the_date('l - F jS', '<h2>', '</h2>'); ?></font></div>
    </a>

Topic Closed

This topic has been closed to new replies.

About this Topic