Jump to content

What's Difference Between For Ex Name=\"com\" And Name="com"


medicalboy
 Share

Recommended Posts

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

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. :)

Edited by Deirdre's Dad
Link to comment
Share on other sites

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

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

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

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

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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...