Re: [PHP] Quotes vs. Single Quote

[email protected] (tedd)
Newsgroups php.general
Message-ID <p06240803c881ac0a988f@[192.168.1.104]>
At 11:00 PM -0400 8/5/10, Paul M Foster wrote:
>On Thu, Aug 05, 2010 at 10:10:26PM -0400, Rick Dwyer wrote:
>
>  > echo "<table border='1'><tr>....
>>
>>  And elsewhere on the page it follows:
>>
>  > echo '<table border="1"><tr>....
>
>Not acceptable and sloppy. Be consistent in your coding style. In
>general, HTML attributes should be surrounded by double quotes. I don't
>know about javascript. Moreover, it's generally better to simply output
>HTML rather than to echo it, like:
>
><table border="1"><tr>
><td>
><?php echo $some_value; ?>
></td>

Rick:

I agree with Paul.

I would only add that you should use what languages best serve your 
needs. While it may not be obvious, the statement:

<table border="1">

is flawed (IMO).

The "best" way to handle this is to define a class (or id) for the 
table in a css file and then set the border (i.e., styling) to 
whatever you want. For example, your HTML would look like:

<table class="my_table">

And your CSS would contain:

.my_table
    {
    border: 1px solid black;
    }

That way at some future date, you may want to change the border 
color, size, whatever and it's a trivial thing to do so without 
having to search through all your code to find ill-placed styling 
attributes.

As I always say, neither CSS, PHP, or any web language exist in a 
vacuum. It always best to use whatever language that makes your life 
(and others) simpler.

Cheers,

tedd

PS: Considering that this is Friday. I have a grammar question for 
the group. I said above:

"neither CSS, PHP, or any web language exist in a vacuum."

Is the word "neither" appropriate in this sentence?

Normally, two items can be compared by "neither"  or "nor", but what 
about more than two items? Is it appropriate to use "neither"  or 
"nor" for more than two items?

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.