Quotation mark in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shuhail
Forum Newbie
Posts: 16
Joined: Sun Jun 28, 2009 5:52 am

Quotation mark in php

Post by shuhail »

Hi,

I need to write the following line in php:

Code: Select all

<a href="javascrip:void(0)" onclick="javascript:chatWith('janedoe')">Chat With Jane Doe</a>
but I need to replace the name "Jane Doe" with names selected from my database.

Code: Select all

echo "<a href='javascript:void(0)' onclick='javascript:chatWith("" . $nm . "")'>" .$nm. "</a>";
here I need 3rd type of quotation mark !!!
Please someone tell me how to fix this.


Thanks.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Quotation mark in php

Post by Darhazer »

You don't need, you can escape quotes with a slash

Code: Select all

echo "<a href=\"javascrip:void(0)\" onclick=\"javascript&#058;chatWith('$name')\">Chat With $name</a>";
shuhail
Forum Newbie
Posts: 16
Joined: Sun Jun 28, 2009 5:52 am

Re: Quotation mark in php

Post by shuhail »

Code: Select all

echo "<tr><td><a href=\"javascript:void(0)\" onclick=\"javascript:chatWith('".$nm1."')\">".$nm."</a></td></tr>";

Thanks. It works.
Post Reply