Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Tags for this Thread

+ Reply to Thread
Results 1 to 2 of 2
  1. #1

    A variable that holds other variables? PHP?

    I tried heredocs, but I think heredocs don't support PHP codes.

    For example

    $php = <<<phpcode
    <?php
    $var = 'This is a var';
    $time = 2;
    ?>
    phpcode;

    That didn't work.. how do I hold php codes inside a variable?
    Thanks.
    But there not like the example above they are much longer variables.. for example..

    $roundedtime = round($totaltime,$round);

    Would I put that into an array?
    Thanks, I keep confusing myself with functions and arrays.

  2. #2
    Lost in life's Avatar
    Junior Member

    Status
    Offline
    Join Date
    Jun 2009
    Posts
    7
    Downloads
    0
    Uploads
    0
    what are you trying to do? "A variable that holds other variables" sounds like an array to me.

    $php = array("This is a var", 2);

    echo $php[0]; // displays "This is a var"
    echo $php[1]; // displays 2

 

 

Quick Reply Quick Reply

Click here to log in


What comes after M0nday

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 12-09-2011, 05:09 AM
  2. Replies: 0
    Last Post: 12-12-2009, 04:17 AM
  3. Using php variables - if variable doesn't exist problem?
    By Gregory Heinz in forum Discuss PHP
    Replies: 0
    Last Post: 11-22-2009, 08:11 PM
  4. Replies: 0
    Last Post: 09-30-2009, 03:36 AM
  5. Replies: 0
    Last Post: 12-03-2008, 05:49 PM

Bookmarks

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •