2016-09-27 129 views
-1

假设我有一个字符串作为如何将包含HTML标签和php变量的字符串转换为php字符串变量?

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); ?> 

我怎样才能把这个整个字符串成一个PHP变量,使所有的PHP变量转换成它们各自的值?

回答

2

你应该试试这个,

<?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); 
?> 
0

您可以使用htmlentities字符串和html_entity_decode转换为字符串解码。希望这会帮助你。