在html链接中调用javascript函数[关闭]

im a little stuck. im trying to call a javascript alert when clicking on a link like so

 <a onclick="return confirm('Are you sure?')" href="blog-delete.php?blogid=1">Delete</a>

which works fine, But im trying to call it inside a php var lik so

 $blogtitle . '<p align="right" style="font-size:10px;" ><a onclick="return confirm("Are you sure?")" href="blog-delete.php?blogid=' . $blogid . '">Delete</a> | '. $blogdate . '</p></div> <br />  ';

but the double qoute dont allow for the function to work

anyhelp would be great

Many thanks

escape " by \ try this

 $blogtitle . '<p align="right" style="font-size:10px;" ><a onclick="return confirm(\"Are you sure?\")" href="blog-delete.php?blogid=' . $blogid . '">Delete</a> | '. $blogdate . '</p></div> <br />  ';

use single quotes instead of double quotes

$blogtitle . '<p align="right" style="font-size:10px;" >
         <a onclick="return confirm('Are you sure?')" href="blog-delete.php?blogid=' . $blogid . '">Delete</a> | '. $blogdate . '</p></div> <br />  
 ';

You are messing up your quotes. When you write this:

$v = "This is "some" text";

You have double quotes within double quotes, which confuses the parser (as also shown by the syntax highlighter of StackOverflow). To fix, you have to "escape" the ones inside the string:

$v = "This is \"some\" text";

Or use single quotes:

$v = 'This is "some" text';

(A lot) more information is found here: http://php.net/manual/en/language.types.string.php I'd say bookmark that PHP documentation site, it is very good and extensive.

Good luck in learning PHP!

Use \ as an escape character.

More importantly, read up on Unobtrusive Javascript to see why having calls to Javascript functions in your HTML is now considered deprecated practice.

try adding '\'.It will work. "" signs operarte on a nearest closing tags.thats why it s not working.