Reputation: 31
How can I do somethink like this with PHP DOM?
<img src="<?php echo $picsrc; ?>">
This Code
$node->setAttribute('src','<?php echo $picsrc;?>');
does escape the PHP Tag.
<img src="<?php echo $picsrc; ?>">
Is there a way to use
$dom->createProcessingInstruction()
for Attribute Values?
Upvotes: 3
Views: 252
Reputation: 31
@thecatontheflat was right, decoding is the Answer!
But using it this way:
$node->setAttribute('src','<?php echo $picsrc; ?>');
$doc->save('dynamic.php');
$html = htmlspecialchars_decode(file_get_contents('dynamic.php'));
$html = html_entity_decode($html);
file_put_contents('dynamic.php',$html);
Don't try to avert the conversion, just revoke it. ;)
thanks at all.
Upvotes: 0
Reputation: 17976
You should try this
$srcPath = '<?php echo $picsrc;?>';
$node->setAttribute('src', html_entity_decode($srcPath));
Upvotes: 1