Current location: Hot Scripts Forums » Programming Languages » PHP » What it the use of \" in PHP?


What it the use of \" in PHP?

Reply
  #1 (permalink)  
Old 09-15-03, 06:01 PM
iRuben iRuben is offline
New Member
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
What it the use of \" in PHP?

What is the use of al this crappy \" formatting in PHP??? For instance, a line like this:
Code:
echo "<table align=\"center\" width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
Works just as well when entered like this:
Code:
echo "<table align='center' width='95%' border='0' cellspacing='0' cellpadding='0'>"
...which is a lot clearer in my opinion. I don't like this \" format at all, makes my code harder to read, what is the exact use why 95% of all PHP code is made like this?
Reply With Quote
  #2 (permalink)  
Old 09-15-03, 07:39 PM
the|Skrilla the|Skrilla is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Louisiana, USA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
I use the single-quote on all of my php sccripts instead of the double-quote.

And I think the reason people commonly use the double-quote is because it is a standard and they might not know that a single-quote works.
__________________
Lead Level Designer - Liquid Element
Reply With Quote
  #3 (permalink)  
Old 09-16-03, 05:35 AM
ermau's Avatar
ermau ermau is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Florida, USA
Posts: 240
Thanks: 0
Thanked 0 Times in 0 Posts
Because a single quote in defining a value of an html attribute is not valid. Double quotes are the only valid way to do it, but you should do it like this:

PHP Code:

echo '<table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">'
Some browsers sometime freak out if you don't have double quotes around the attribute values.. besides it's the way it's supposed to be done anyways.
__________________
PHP / mySQL Developer
Reply With Quote
  #4 (permalink)  
Old 09-16-03, 09:21 AM
jewellgr jewellgr is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Michigan USA
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Also, when I am saving info to store into a csv like this:
PHP Code:

$results .= "$name,$phone\n"
If I used this instead:
PHP Code:

$results .= '$name,$phone\n'
It puts the endline (\n) into the cell with the phone information instead of actually breaking the line.
So using double quotation produces this:
Gregg| 555.555.5555
Jewell|222.222.2222

Using single quotation produces this:
Gregg|555.555.5555\n|Jewell|222.222.2222\n....
__________________
ArecaWeb Team
Gregg Kenneth Jewell

Last edited by jewellgr; 09-16-03 at 09:24 AM.
Reply With Quote
  #5 (permalink)  
Old 09-16-03, 09:33 AM
iRuben iRuben is offline
New Member
 
Join Date: Sep 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for the replies and the additional info on the \n thing. I don't think I've used the \n anywhere in my site, but I'll keep this in mind in case something doesn't work right.

For now, I have changed all \" occurances into ' and everything seems to be okay and my code is a lot more readable. :-D
Reply With Quote
  #6 (permalink)  
Old 09-16-03, 09:53 AM
nefariousphp nefariousphp is offline
Banned
 
Join Date: Aug 2003
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
The main reason is because HTML 4.0 is not compatiable inside php coding.

<table width=\"100%\"> is called XHTML
Also maybe seen like this <br /> or <p />
Reply With Quote
  #7 (permalink)  
Old 09-16-03, 10:50 AM
kennethlove666 kennethlove666 is offline
Newbie Coder
 
Join Date: Aug 2003
Location: oklahoma
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
nefariousphp - that's not exactly right.
you've always been SUPPOSED to use "'s and closing tags in HTML. it's just that it's required in XHTML.
Reply With Quote
  #8 (permalink)  
Old 09-16-03, 11:58 AM
nefariousphp nefariousphp is offline
Banned
 
Join Date: Aug 2003
Posts: 129
Thanks: 0
Thanked 0 Times in 0 Posts
Go to www.php.net, tell them that, lmao

Good day =)
Reply With Quote
  #9 (permalink)  
Old 09-16-03, 07:23 PM
ermau's Avatar
ermau ermau is offline
Wannabe Coder
 
Join Date: Aug 2003
Location: Florida, USA
Posts: 240
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally posted by nefariousphp
The main reason is because HTML 4.0 is not compatiable inside php coding.

<table width=\"100%\"> is called XHTML
Also maybe seen like this <br /> or <p />
\" is NOT XHTML, /> is, \" isn't. :

$results .= '$name... wouldn't work, php won't parse that, it should be $results .= $name.','.$phone;
__________________
PHP / mySQL Developer
Reply With Quote
  #10 (permalink)  
Old 09-16-03, 07:32 PM
the|Skrilla the|Skrilla is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Louisiana, USA
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
true. The backslash is simply a delimiter, telling php to ignore any meaning for the proceeding character, just like in regular expressions.
__________________
Lead Level Designer - Liquid Element
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP Dudes - Hi All stuart New Members & Introductions 4 05-03-04 01:22 PM
Custom PHP Scripts BdSBB Job Offers & Assistance 3 12-07-03 09:49 AM
PHP Triad/Upload form eddyvlad PHP 6 10-06-03 11:17 PM
Ad management and optimisation using php surebetdmg PHP 0 08-28-03 06:45 PM


All times are GMT -5. The time now is 06:11 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.