What's wrong with this.. $text.( ...

Discussion in 'PHP' started by cyclotron, Nov 15, 2009.

  1. #1
    $z3 = "juice";
    
    
    $text = "";
    
    if ($firstname == "z") {
    	$text.=('. $z3 .'); 
    }
    
    echo $text;
    PHP:

    Text should echo 'juice'

    Hmm.
     
    cyclotron, Nov 15, 2009 IP
  2. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #2
    $firstname is not defined and hence its value is blank ('').
    that is why if condition will become false leaving $text unchanged :)
     
    mastermunj, Nov 15, 2009 IP
  3. cyclotron

    cyclotron Active Member

    Messages:
    213
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    73
    #3
    There's more to the script, $firstname is set.. But it's echoing this.

    . $z3 .
     
    cyclotron, Nov 15, 2009 IP
  4. mastermunj

    mastermunj Well-Known Member

    Messages:
    687
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    110
    #4
    please post more part of script to help us determine what is wrong!
     
    mastermunj, Nov 15, 2009 IP
  5. cyclotron

    cyclotron Active Member

    Messages:
    213
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    73
    #5
    Obviously this isn't right..

    $text.=('. $z3 .');

    It should be something like $text.=($z3);

    but that produces an error.
     
    cyclotron, Nov 15, 2009 IP
  6. cyclotron

    cyclotron Active Member

    Messages:
    213
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    73
    #6
    Nevermind I worked it out. Had some error elsewhere.

    FML.
     
    cyclotron, Nov 15, 2009 IP