medicalboy Posted November 10, 2009 Share Posted November 10, 2009 i know my q is stupid but i am abeginner and i read many scripts S.C for learningwhat's the difference between the value of name in the form name=\"com\" and name="com"i mean \""\ ?othe questions:enctype='multipart/form-data' what's this do ? Link to comment Share on other sites More sharing options...
Ingolme Posted November 10, 2009 Share Posted November 10, 2009 The \ is just used so that a quotation mark doesn't behave as a string delimiter.For exampe:echo "<a href=\"something\">Text</a>";"multipart/form-data" is the form encoding that will allow files to be uploaded to the server. Link to comment Share on other sites More sharing options...
jeffman Posted November 10, 2009 Share Posted November 10, 2009 If you tried this:$str = "<a href="something">Text</a>";PHP would try to assign the value between the first 2 double-quote marks to $str. So $str would hypothetically equal "<a href=" . Since the text that comes after that doesn't read like a PHP statement, you would also throw an error. This is true of all programming languages I know of.One solution is to use single quotes. The following is fine (and actually preferred in PHP style):$str = '<a href="something">Text</a>';When you put the \ character before something in some contexts (like inside double quotes in PHP) it is being used as an escape character. To write \"blah\" is to escape the quotation marks.Escaping a character doesn't always do the same thing. To escape quotation marks means to treat them like regular characters, not like string delimiters. But some escape sequences change regular characters into special characters, which is kind of the other way around. "\n" is treated as a newline character (it begins a new line in plain text). "\t" is a tab. There are others, too.I find escaped quotation marks hard to read and avoid them whenever possible. Link to comment Share on other sites More sharing options...
Synook Posted November 10, 2009 Share Posted November 10, 2009 There is also HEREDOC syntax, for very large strings. Link to comment Share on other sites More sharing options...
medicalboy Posted November 10, 2009 Author Share Posted November 10, 2009 thanx , now it's clear am appreciated for ur help Link to comment Share on other sites More sharing options...
medicalboy Posted November 10, 2009 Author Share Posted November 10, 2009 The \ is just used so that a quotation mark doesn't behave as a string delimiter.For exampe:echo "<a href=\"something\">Text</a>";"multipart/form-data" is the form encoding that will allow files to be uploaded to the server.well but the output for this echo will be textand this equal as we used the value delimited inside quotation marks!so what's the significance? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 10, 2009 Share Posted November 10, 2009 Look at how quotes form a string. This is a string:$str = "some string";So what happens if you want a double quote to appear inside a double-quoted string? If you just added the quote:$str = "quoted " string";The quote will end the string and create an error. You need the slash to tell it that you want a double quote to appear inside the double-quoted string:$str = "quoted \" string";You can also mix quote types:$str = 'quoted " string';$str = "quoted ' string"; Link to comment Share on other sites More sharing options...
medicalboy Posted November 10, 2009 Author Share Posted November 10, 2009 Look at how quotes form a string. This is a string:$str = "some string";So what happens if you want a double quote to appear inside a double-quoted string? If you just added the quote:$str = "quoted " string";The quote will end the string and create an error. You need the slash to tell it that you want a double quote to appear inside the double-quoted string:$str = "quoted \" string";You can also mix quote types:$str = 'quoted " string';$str = "quoted ' string";good ,for this usage it's okbut in this snippet code<input type=\"radio\" value=\"install\" name=\"com\"><font color= '#000000 '><b> upgrade </b></font> <br><input type=\"radio\" value=\"updata\" name=\"com\"><font color= '#000000 '><b>install why did the programmer write it using slash not inside quotes normally? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 10, 2009 Share Posted November 10, 2009 It all depends on the context where that appears. If that appears in a context like this: <?php echo "<input type=\"radio\" value=\"install\" name=\"com\"><font color= '#000000 '><b> upgrade </b></font> <br><input type=\"radio\" value=\"updata\" name=\"com\"><font color= '#000000 '><b>install ";?> Then the slashes are needed because everything is inside a double-quoted string, being printed by PHP. If that appears in regular HTML code, not inside a PHP block being printed in a double-quoted string, then the slashes aren't necessary (and even incorrect, for HTML). That could also appear in a piece of Javascript code inside a double-quoted string and would also need the slashes in that context. Link to comment Share on other sites More sharing options...
Ingolme Posted November 10, 2009 Share Posted November 10, 2009 good ,for this usage it's okbut in this snippet code<input type=\"radio\" value=\"install\" name=\"com\"><font color= '#000000 '><b> upgrade </b></font> <br><input type=\"radio\" value=\"updata\" name=\"com\"><font color= '#000000 '><b>install why did the programmer write it using slash not inside quotes normally? Probably because he copied the code from somewhere else and didn't know what he was doing. Given the <font> and <b> tags, it seems quite likely. Link to comment Share on other sites More sharing options...
medicalboy Posted November 10, 2009 Author Share Posted November 10, 2009 It all depends on the context where that appears. If that appears in a context like this:<?php echo "<input type=\"radio\" value=\"install\" name=\"com\"><font color= '#000000 '><b> upgrade </b></font> <br><input type=\"radio\" value=\"updata\" name=\"com\"><font color= '#000000 '><b>install ";?> Then the slashes are needed because everything is inside a double-quoted string, being printed by PHP. If that appears in regular HTML code, not inside a PHP block being printed in a double-quoted string, then the slashes aren't necessary (and even incorrect, for HTML). That could also appear in a piece of Javascript code inside a double-quoted string and would also need the slashes in that context. yeah , understood nowreally i didn't notice the beginning of the echo in the code as it's too long and not organized wellthanx brotha so muchi like your descriptiondo u have fb or twitter ac? Link to comment Share on other sites More sharing options...
medicalboy Posted November 10, 2009 Author Share Posted November 10, 2009 Probably because he copied the code from somewhere else and didn't know what he was doing. Given the <font> and <b> tags, it seems quite likely.yeah, i think he used asupported prog to write the html codes i checked his script as it's cms script was written something easily and not complicated Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.