如何将包含HTML标签和php变量的字符串转换为php字符串变量?

Suppose I have a string as

    Hi, <br><br>
Someone has shared a <?php echo $job_type ?> with you through <?php echo CHtml::link(Yii::params['Data_Port'], Yii::app()->getBaseUrl(true)); ?>.<br><br>
Title: <?php echo $job_title;?><br><br>
<?php echo CHtml::link("View"." ".ucfirst($job_type)." "."Details", $job_link); ?>

How can I put this whole string into a php variable so that all the php variables are converted into their respective values?

You should try this,

<?php 
$str='';
$str.="Hi, <br><br> Someone has shared a ";
$str.=$job_type;
$str."with you through";
$str.=CHtml::link(Yii::params['Data_Ports'], Yii::app()->getBaseUrl(true));
$str.="<br><br>";
$str.="Title:";
$str.=CHtml::link("View"." ".ucfirst($job_type)." "."Details", $job_link);
?>

You can use htmlentities to convert the string and html_entity_decode to decode that string. Hope this will help you.