2016-09-27 123 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轉換爲字符串解碼。希望這會幫助你。