Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

double vs single quotes #73

Closed
aleemb opened this issue Mar 17, 2014 · 4 comments
Closed

double vs single quotes #73

aleemb opened this issue Mar 17, 2014 · 4 comments

Comments

@aleemb
Copy link

aleemb commented Mar 17, 2014

What is the motivation for single vs double quotes?

It is often desirable to switch between the two as per convenience. For example in PHP it is better to write (1) echo "<a href='$href'>"; as opposed to (2) "echo <a href=\"$href\">";.

HTML and for that matter most other languages allow for single versus double quotes for this reason.

@ritcheyer
Copy link

Why couldn't you simply solve this in your PHP using single quotes?

echo '<a href="$href">';

@aleemb
Copy link
Author

aleemb commented Mar 17, 2014

PHP doesn't allow variables inside single quotes and treats them as literals.

 $href = "foo";
 echo '<a href="$href">'; // outputs <a href="$href">
 echo "<a href='$href'>"; // outputs <a href='foo'>

This is a very common idiom in PHP.

@mdo
Copy link
Owner

mdo commented Mar 17, 2014

This is an HTML and CSS code guide, so it doesn't take any other programming language into account for the most part. That sounds like a pretty shitty limitation on PHP's part though 😆.

@mdo mdo closed this as completed Mar 17, 2014
@ritcheyer
Copy link

👍 haha

On Mon, Mar 17, 2014 at 10:45 AM, Mark Otto notifications@github.comwrote:

Closed #73 #73.

Reply to this email directly or view it on GitHubhttps://github.com//issues/73
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants