c++ bbcode system problem with html = #include <header.h>
hello I have a very awkward problem, I've made a code system for normal code and one for php so that the output is highlighted however I have a problem with code that is C++.
Due to the nature of the code e.g.
the php script will take not display <header> instead its hidden in the actual source of the html. Example:
Code:
#include <iostream><br />
#include <string><br />
The output is #include without the <headers>, any suggestions.
Re: c++ bbcode system problem with html = #include <header.h>
well I worked out I need to use htmlentities but now I'm havnig problems with double quotes, it puts a \ before the quote, I need the quote to be left alone.
Re: c++ bbcode system problem with html = #include <header.h>
Turn off Magic Quotes in php.ini.
If you don't have access to that, you can use a different quote conversion method:
PHP Code:
echo htmlentities($code, ENT_QUOTES);
But you should turn off magic quotes if you can anyway, its a silly feature.
Re: c++ bbcode system problem with html = #include <header.h>
I've tried that and cannot get it going, heres what I'm using:
PHP Code:
function code($str){
$match = array('#\[code\](.*?)\[\/code\]#se');
$replace = array("'<table width=\"95%\" align=\"center\"><tr><td class=\"php_head\"><b><u>Code Snippet</u></b></td></tr><tr valign=\"top\"><td class=\"code_body\" align=\"left\">'.htmlentities('$1', ENT_QUOTES).'</td></tr></table>'");
return preg_replace($match, $replace, $str);
}
OUTPUT:
cout << endl << \"\tWhat is your name? \";
system(\"pause\");
return 0;
really messes up my C++ code also I'm on shared hosting, I will have to ask my host about magic quotes. Mean time any other suggestions?
Re: c++ bbcode system problem with html = #include <header.h>
Use stripslashes() on the resultant output.