houdriwiokug houdriwiokug - 3 months ago 8
MySQL Question

How to echo out PHP variables while you are echoing another statements

I've got a very big problem. My problem is that I don't know exactly how to echo out a PHP variable while I'm echoing another statements. Here is the example:

<?php if ($dataSet->GetLevel()==1){
echo "
<div class='row'>
<div class='col-md-6'>
<div class='box box-primary'>
<div class='box-header'>
<h3 class='box-title'>General Settings:</h3>
</div>
<div class='box-body'>
<div class='form-group'>
<label>Site Title:</label>
<input type='text' class='form-control' id='usr' value='".echo $siteSet->GetSitetitle()."'>
</div>
<div class='form-group'>
<label>Site Tags:</label>
<input type='text' class='form-control' id='usr' value='".echo $siteSet->GetSitetags()."'>
</div>
<div class='form-group'>
<label>Site Description:</label>
<input type='text' class='form-control' id='usr' value='".echo $siteSet->GetSitedesc()."'>
</div>
</div>
</div>
</div>
</div>
";
} ?>


As you can see I have checked a statement and then I tried echoing out a div and after that I wanted to echo out another variable so I tried some indenting however it does not work properly! Can you please tell me what's the correct way to do this ?

Here are those 3 sentences that are getting unexpected 'echo' (T_ECHO) error :

echo "
<div class='box-body'>
<div class='form-group'>
<label>Site Title:</label>
<input type='text' class='form-control' id='usr' value='".echo $siteSet->GetSitetitle()."'>
</div>
<div class='form-group'>
<label>Site Tags:</label>
<input type='text' class='form-control' id='usr' value='".echo $siteSet->GetSitetags()."'>
</div>
<div class='form-group'>
<label>Site Description:</label>
<input type='text' class='form-control' id='usr' value='".echo $siteSet->GetSitedesc()."'>
</div>
</div>
";

Answer

Try to change

value='".echo $siteSet->GetSitetitle()."'

to

value='{$siteSet->GetSitetitle()}'
Comments