Based on the work of Stevarino and to answer to WordPress Forum, here is another version :

I found the problem….It comes the formatting functions which convert few “special” characters into more fancy one….


function run_phpinpost($data) {
$PHPTag = "phpcode";
$data = str_replace(array("rn","r"), "n", $data);
while (false !== strpos($data, "< ".$PHPTag .">")) {
$Before= substr($data, 0, strpos($data, "< ".$PHPTag.">"));
$After = substr($data, strpos($data, "")+(strlen($PHPTag)+3));
$Evaluate = substr($data, strpos($data, "< ".$PHPTag.">")+(strlen($PHPTag)+2));
$Evaluate = substr($Evaluate,0,strpos($Evaluate, "")-1);
$Evaluate = str_replace(array("’","‘"),"'", $Evaluate);
$Evaluate = str_replace(array("”","“"),'"', $Evaluate);
ob_start(); // run that data and grab what comes out
eval($Evaluate);
$data = $Before.ob_get_clean().$After;
} // end of while
return $data;
} // end of run_phpinpost

add_filter('the_content', 'run_phpinpost');

to use it, simply put the code above in “my-hacks.php”, and in your post use the tags :
<phpcode>php executable code </phpcode>

By the way if you are using an “old” PHP version, the function ob_get_clean() is not existing so :

// To add compatibility with earlier PHP version...(before 4.3.0)
if (!function_exists("ob_get_clean")) {
function ob_get_clean() {
$ob_contents = ob_get_contents();
ob_end_clean();
return $ob_contents;
}
}