php - Is this the Correct way of passing the Single quotes and double quotes in the string -


'<a href="javascript:void(0)" onclick="function(\''.$row['stuid'].'\')">print student details</a>'; 

is correct way of passing single quotes , double quotes in statement

yes, is. first escape single quotes passed output , quote function-argument. inside them have quotes separate string php variable.

and not have escape double quotes inside php string because single-quote delimited.

$string = "this 'valid' string."; $string = 'this \'valid\' string.'; $string = 'this "valid" string.'; $string = "this \"valid\" string."; $valid = "valid"; $string = "this '".$valid."' string."; $string = 'this \''.$valid.'\' string.'; $string = 'this "'.$valid.'" string.'; $string = "this \"".$valid."\" string."; $string = "this '$valid' string"; //as rocket said $string = 'this not "$valid" string'; //works in double quotes $string = "this '{$row['valid']}' string"; //as rocket said 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -