[Solved] Error PHP Twitter share [closed]


You either need to escape all of the single quotes in that string or don’t use PHP to output that code (recommended):

<?php 
//some php code
?>
<a href="https://twitter.com/share" class="twitter-share-button" data-via="User" data-size="large">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?''http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<?php
// more PHP code
?>

Escaped quotes:

<?php echo '<a href="https://twitter.com/share" class="twitter-share-button" data-via="User" data-size="large">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>'; ?>

1

solved Error PHP Twitter share [closed]