bakum
asked on
outputting linebreaks in HTML comments
Hi, I've got some PHP code which strings together some HTML output based on some various factors. My problem is the resulting code looks like one big solid block of text in the HTML comments. I want it to be clean and neat with line breaks between the elements as if I coded directly to HTML. Any clues how to do this?
thanks!
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry, meant points to you. why did I write me?
Incidentally, you have to use " in your PHP code for them to work. If you have say $myCode = '<a href="/index.php">home</a> \n'; that doesn't work for some reason. but flip the quotes and it does. That was about ten minutes of head bashing right there.
Incidentally, you have to use " in your PHP code for them to work. If you have say $myCode = '<a href="/index.php">home</a>
> sorry, meant points to you. why did I write me?
Yeah, that was a little confusing. :)
I'm glad that I could help you. Strings in double quote marks are processed a little differently from those with single quotes. The issue you found is similar to not being able to reference a variable in a string with single quotes but you can with double quotes. For example ...
echo "Hi from $me"; //will work
echo 'Hi from $me'; //will not work
echo 'Hi from ' . $me; //will work
I would normally write the line in your last comment like this ...
$myCode = "<a href=\"/index.php\">home</ a>\n"; // the backslash (\) escapes the "
Thank you for the grade, the points and the fun question. I'm glad that you are making the effort to make the html readable. I believe it is worth it.
bol
Yeah, that was a little confusing. :)
I'm glad that I could help you. Strings in double quote marks are processed a little differently from those with single quotes. The issue you found is similar to not being able to reference a variable in a string with single quotes but you can with double quotes. For example ...
echo "Hi from $me"; //will work
echo 'Hi from $me'; //will not work
echo 'Hi from ' . $me; //will work
I would normally write the line in your last comment like this ...
$myCode = "<a href=\"/index.php\">home</
Thank you for the grade, the points and the fun question. I'm glad that you are making the effort to make the html readable. I believe it is worth it.
bol
ASKER