This is probably a very simple question, but I just can't figure it out. I want to define a string containing two forward slashes
$htmlcode="text//text";From what I understand what follows after // are comments.
Question: How do create a string containing //?
3 Answers
Parsing of the language is a little bit tricky. Within a string literal, comments and other language features are not triggered (except for special characters which need to be escaped). Also, within block comments, line-comments are not valued.
$example1 = 'hello /* this is not a comment */ '; /* but this is */
$example2 = 'hello // this is not a comment '; //but this is
$example3 = "works the same with double quotes /* not a comment */ //not a comment ";
/* comment example $thisIsAComment //this does not escape the closing */ $htmlcode="text//text"; //this is comment.Your string is already defined as you want it to be. Check out docs:
You should use some IDE or syntax highlighter, you will understand code more clearly. Notepad++ is free and lightweight
1Your code is fine.
I would highly suggest reading the Basic Syntax - Comments guide to get a better understanding.
3