What's the best practice to set html attribute via PHP?

When doing this job in PHP,one may meet this kind of issue:\[code\]<span title="<?php echo $variable;?>">...\[/code\]The problem is that if \[code\]$variable\[/code\] contains double quotes,should change it to \[code\]\"\[/code\]And that's not the whole story yet:\[code\]<span title='<?php echo $variable;?>'>...\[/code\]In this case,we need to change single quotes to \[code\]\'\[/code\],but leave double quotes as is.So how can we do it in a general property manner?
 
Back
Top