Aphp73 Posted November 14, 2006 Share Posted November 14, 2006 Hey all, I just got some help with submitting a form to the same page. But I don't know what the \ does as in a line like this...echo "<form name=\"8Ball\" action=\"\" method=\"post\">\n"; . Thanks again for any help, I'm a total noob but I need to learn this. Link to comment https://forums.phpfreaks.com/topic/27197-backslash/ Share on other sites More sharing options...
printf Posted November 14, 2006 Share Posted November 14, 2006 \' <= escapes the character that comees after it!You really don't ever need to use them in a example like yours. If you use double quotes inside the variable assignment or language construct, just use single quotes to enclose it, doing the opposite, just reverse what I said previously!example...double inside, single enclose[code]echo '<form action="" method="post">';[/code]single inside, double enclose[code]echo "<form action='' method='post'>";[/code]Of course there will be times you made need to use the escape or backslash, like when you may need to quote a name O\'Hare or other types of strings that are using ([b]'[/b], [b]"[/b]) as there enclosing character! Link to comment https://forums.phpfreaks.com/topic/27197-backslash/#findComment-124411 Share on other sites More sharing options...
CheesierAngel Posted November 14, 2006 Share Posted November 14, 2006 Even working with 2 different kinds of quotes can become really complicated.I mostly echo html or javascript like:[code]<?php $output = <<<HTML <form action="" method="post"> <input type="hidden" name="hidden1" value="$value"> </form>HTML;echo $output;?>[/code]Like this you avoid working with different kind of quotes nesting in eachother, it can still occur but its rather an exception. Link to comment https://forums.phpfreaks.com/topic/27197-backslash/#findComment-124416 Share on other sites More sharing options...
alpine Posted November 14, 2006 Share Posted November 14, 2006 or simply echo it out[code]<?phpecho <<<_HTML"whatever" $html u want to print_HTML;?>[/code] Link to comment https://forums.phpfreaks.com/topic/27197-backslash/#findComment-124419 Share on other sites More sharing options...
CheesierAngel Posted November 14, 2006 Share Posted November 14, 2006 [quote author=alpine link=topic=114917.msg467786#msg467786 date=1163512518][code]<?phpecho <<<_HTML"whatever" $html u want to print_HTML;?>[/code][/quote]Is there a difference between the <<<HTML and <<<_HTML ? Link to comment https://forums.phpfreaks.com/topic/27197-backslash/#findComment-124423 Share on other sites More sharing options...
alpine Posted November 14, 2006 Share Posted November 14, 2006 No, you can call it whatever you want as long as you close it with the same identifyer<<<EASYEASY;<<<___WOW___WOW;But remember, the closing part MUST be absolute left on a new line - no spaces Link to comment https://forums.phpfreaks.com/topic/27197-backslash/#findComment-124424 Share on other sites More sharing options...
CheesierAngel Posted November 14, 2006 Share Posted November 14, 2006 ok, thanks didn't knew that. Link to comment https://forums.phpfreaks.com/topic/27197-backslash/#findComment-124425 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.