Search code examples
phpquotesfwrite

fwrite quotes in href


I'm having trouble with href quotes inside the fwrite. What I have no is something like this:

fwrite($fp, "Some text ".$SomeVar." some text :".$SomeVar.". Some text <a href="https://www.google.com/" target="_blank"><br>Some text <a href="https://www.google.com/" target="_blank">");

Is there any way to make those href quotes mark as plain text?

I have read somewhere that using double quotes might help, but it doesn't. I have also tried:
<a href="https://www.google.com/\" target="_blank\">

Thank you.


Solution

  • It's easier to use single quotes when your string contains double quotes:

    $string = '<a href="https://cia.gov">CIA</a>';
    

    Or, you can escape the quotes like this:

    $string = "<a href=\"https://cia.gov\">CIA</a>";