Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

In PHP, is visible to access variable that is inside another variable? ex : i need to get $value that is inside $output1

if ($nilaineg > $nilainet && $nilaineg > $nilaipos) {
  $output1 = '<div class="message"> ' . $tweet . ' </div>
     <div class="hasil">'.**$value** .'</div> </div>';
}
else if ($nilaipos > $nilaineg && $nilaipos > $nilainet){
   $output2 = '<div class="message"> ' . $tweet . ' </div>
      <div class="hasil">'. $value .'</div> </div>';        
}
share
Can you clarify your question? In current situation this is not clear. – Yogesh Suthar 5 mins ago
What you actually needed here? – Sibiraj PR 4 mins ago

1 Answer

$value isn't "inside" $output1. $value is a variable just like $output1 which is used in a string concatenation. You can still use $value outside and independently of the string concatenation and $output1.

$output1 .= '<div class="message"> ' . $tweet . ' </div>
             <div class="hasil">' . $value . '</div> 
             </div>';

echo $output1;
echo $value;
share

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.