Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP : How to print Php syntax in html

Tags:

php

I am wondering is it possible to print php syntax on html page.For example below is the php syntax i want to echo on html page via php.

Please <?php echo $random[array_rand($random)]; ?> the [url=http://feeds.feedburner.com]hello[/url].<br>
Also [url=http://feeds.feedburner.com]<?php echo $random[array_rand($random)]; ?>[/url].
<br> 
like image 247
user2361154 Avatar asked Dec 07 '22 07:12

user2361154


1 Answers

Try this:

<?php

$str='Please <?php echo $random[array_rand($random)]; ?> the [url=http://feeds.feedburner.com]hello[/url].<br>
Also [url=http://feeds.feedburner.com]<?php echo $random[array_rand($random)]; ?>[/url].
<br>';

echo highlight_string($str);

?>

Output:

highlights

like image 122
Dave Chen Avatar answered Dec 16 '22 19:12

Dave Chen