我不明白以下行中两个反斜杠的功能...
echo "<p style=\"font-family: $font; font-size: {$size}em;\">Hello, world!</p>";
这段代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Saying hello with style</title>
<link rel="stylesheet" type="text/css" href="common.css" />
</head>
<body>
<h1>Saying hello with style</h1>
<?php
function helloWithStyle( $font, $size ) {
echo "<p style=\"font-family: $font; font-size: {$size}em;\">Hello, world!</p>";
}
helloWithStyle( "Helvetica", 2 );
helloWithStyle( "Times", 3 );
helloWithStyle( "Courier", 1.5 );
?>
</body>
</html>
删除两个反斜杠会导致“预期,或;” 上面粘贴的代码行出错。为什么是这样?
谢谢