我现在这样做:
<a title="<?php echo $title; ?>">...
Run Code Online (Sandbox Code Playgroud)
但是,当"包括在$ title中时,它会变得很糟糕.
并不是说它是"最终的解决方案",但显然你需要转义任何不包含HTML的文字字符串.在这种情况下:
<a title="<?php echo htmlspecialchars($title); ?>">
Run Code Online (Sandbox Code Playgroud)