如何将包含HTML标签和php变量的字符串转换为php字符串变量?
问题描述:
假设我有一个字符串作为如何将包含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变量转换成它们各自的值?
答
你应该试试这个,
<?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);
?>
答
您可以使用htmlentities
字符串和html_entity_decode
转换为字符串解码。希望这会帮助你。