Try using the php function addslashes:
<?php
$str = "Is your name O'reilly?";
// Outputs: Is your name O\'reilly?
echo addslashes($str);
?>
So for EE you could have something like:
(UPDATE 1: the following does not work:)
<p>This is the title and excerpt of this entry: "
<?php
$str = "<strong>". addslashes({title}) . "</strong> : ";
$str .= addslashes({post_excerpt}); // combine title and post_excerpt
echo stripslashes($str); // remove the slashes.
?>
"</p>
UPDATE 1 the following does work:
Following the suggestion of th3mus1cman above, this does work in a plugin without needing addslashes:
On your template:
<p>This is the excerpt of this entry: "
{exp:test_php}{post_excerpt}{/exp:test_php}
"</p>
In your test_php plugin:
public function __construct()
{
$ee_str = ee()->TMPL->tagdata;
$new_str = "<strong>". $ee_str . "</strong>";
$this->return_data = $new_str;
}