markcunningham07 Posted July 16, 2010 Share Posted July 16, 2010 Hi, i just want to know how to include " and ? inside echo how do i echo following php code using php <?php $con = mysql_connect("localhost","forum","password"); mysql_close($con) ?> What i came up with is echo "<?php";"; echo "$con = mysql_connect("localhost","forum","password");"; echo "mysql_close($con)"; echo "?> "; but it doesn't work Link to comment https://forums.phpfreaks.com/topic/207920-how-to-include-and-inside-echo/ Share on other sites More sharing options...
trq Posted July 16, 2010 Share Posted July 16, 2010 echo "<?php\";"; echo "\$con = mysql_connect(\"localhost\",\"forum\",\"password\");"; echo "mysql_close(\$con)"; echo "?>"; Link to comment https://forums.phpfreaks.com/topic/207920-how-to-include-and-inside-echo/#findComment-1086964 Share on other sites More sharing options...
PravinS Posted July 16, 2010 Share Posted July 16, 2010 Try this <?php $str .= '<?php'; $str .= ' $con = mysql_connect("localhost","forum","password");'; $str .= ' mysql_close($con);'; $str .= '?>' ; echo $str; ?> Link to comment https://forums.phpfreaks.com/topic/207920-how-to-include-and-inside-echo/#findComment-1086966 Share on other sites More sharing options...
ksakhare Posted July 16, 2010 Share Posted July 16, 2010 You can use following PHP function: highlight_string() Example: <?php highlight_string('<?php phpinfo(); ?>'); ?> Link to comment https://forums.phpfreaks.com/topic/207920-how-to-include-and-inside-echo/#findComment-1086989 Share on other sites More sharing options...
timvdalen Posted July 16, 2010 Share Posted July 16, 2010 of course, <<< also works echo <<<ENDOFBLOCK hi?"yra"??"" ENDOFBLOCK; Link to comment https://forums.phpfreaks.com/topic/207920-how-to-include-and-inside-echo/#findComment-1087021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.