'<a href="javascript:void(0)" onClick="function(\''.$开发者_开发百科row['STUID'].'\')">Print STUDENT DETAILS</a>';
Is this the correct way of passing single quotes and double quotes in the statement
Yes, it is. First you escape the single quotes that are passed to the output and will quote the function-argument. Inside them you have the quotes that separate your string from the php variable.
And you do not have to escape the double quotes inside the php string because it is single-quote delimited.
$string = "this is a 'valid' string.";
$string = 'this is a \'valid\' string.';
$string = 'this is a "valid" string.';
$string = "this is a \"valid\" string.";
$valid = "valid";
$string = "this is a '".$valid."' string.";
$string = 'this is a \''.$valid.'\' string.';
$string = 'this is a "'.$valid.'" string.';
$string = "this is a \"".$valid."\" string.";
$string = "this is a '$valid' string"; //as Rocket said
$string = 'this is NOT a "$valid" string'; //Works only in double quotes
$string = "this is a '{$row['valid']}' string"; //as Rocket said
yes. the difference between single quote and double quotes is that php will try to interpret special chars and variables inside double quotes. But variable interpretation doesn't work with array.
More informations here: http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double
精彩评论