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 Quote 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 "?>"; Quote 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; ?> Quote 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(); ?>'); ?> Quote 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; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.