1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need Help with variables :)

Discussion in 'PHP' started by chister, May 23, 2011.

  1. #1
    Hello,
    I did searched everywhere about this with no hope :(

    if my file like this:

    $MyVar = "TEXT1";
    
    echo $MyVar;
    
    $MyVar = "TEXT2";
    
    PHP:
    I want the output to be: TEXT2 not TEXT1
    In brief I want to call the variable before it get called :)

    Is there any way to do this?? :D
    Thanks
     
    chister, May 23, 2011 IP
  2. HungryMinds

    HungryMinds Active Member

    Messages:
    216
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    63
    #2
    It's Hard To Understand Your Problem :S

    Please Describe Clearly.
     
    HungryMinds, May 23, 2011 IP
  3. Sefrez

    Sefrez Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The PHP interpreter parses code from top to bottom. You can't output a stream of a variable without first defining it. Why would you want to, anyway?
     
    Sefrez, May 23, 2011 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    this is procedural, keep in mind that in procedural method its from left to right, top to bottom.

    use switch condition, or put in function better yet in a class
     
    bartolay13, May 24, 2011 IP
  5. chister

    chister Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks so much guys.. I fixed it by including files with get method :)
     
    chister, May 24, 2011 IP